I need to add a delay in my code for few seconds, for which I was using the following code:
Private Sub waitInMilliSeconds(ByVal interval As Integer)
Dim stpwt As New Stopwatch
stpwt.Start()
Do While stpwt.ElapsedMilliseconds < interval
' To allows UI to remain responsive and process other threads
Application.DoEvents()
Loop
stpwt.Stop()
End Sub
It was working fine until I included "Imports CANoe". After which I started getting error message, for line - Application.DoEvents(). Error message is :
'Application' is ambiguous, imported from the namespaces or types 'CANoe, System.Windows.Forms'.
Can someone please help me in sorting this problem? Or with an alternate way of adding delays?
P.S. :
- I am a basic programmer & not an expert in VB.NET, so your comments are very valuable to me.
- I am using Microsoft Visual Basic 2010 Express edition.
- I am using CANoe to send some CAN signals on CAN bus.
- I want to insert a delay which will allow execution of other threads in parallel (Ex: I have a handler which gets called whenever there is data incoming from the COM port. I don't want this to stop when I call a delay function)
Thanks.