C
Charles Law
I have a solution with two projects.
Project1:
---------
Private m_Flagged As Boolean
Private WithEvents m_Project2 As New Project2
Private Sub WaitForFlag()
m_Flagged = False
Do While Not m_Flagged
Thread.Sleep(1)
Loop
MessageBox.Show("Event Occurred.")
End Sub
Private Sub FlagEvent(...) Handles m_Project2.EventOccurred
m_Flagged = True
End Sub
Project2:
---------
Public Event EventOccurred(...)
Private Sub WaitForEvent()
'If Some Event Occurred Then
RaiseEvent EventOccurred(...)
'End If
End Sub
WaitForEvent in Project2 is started on a new thread. The message in
WaitForFlag (Project1) is never displayed as the code stands above. If I
replace the Sleep(1) with DoEvents then it does get displayed.
I thought the whole point of executing on separate threads was that I didn't
need DoEvents anymore. Have I missed something?
TIA
Charles
Project1:
---------
Private m_Flagged As Boolean
Private WithEvents m_Project2 As New Project2
Private Sub WaitForFlag()
m_Flagged = False
Do While Not m_Flagged
Thread.Sleep(1)
Loop
MessageBox.Show("Event Occurred.")
End Sub
Private Sub FlagEvent(...) Handles m_Project2.EventOccurred
m_Flagged = True
End Sub
Project2:
---------
Public Event EventOccurred(...)
Private Sub WaitForEvent()
'If Some Event Occurred Then
RaiseEvent EventOccurred(...)
'End If
End Sub
WaitForEvent in Project2 is started on a new thread. The message in
WaitForFlag (Project1) is never displayed as the code stands above. If I
replace the Sleep(1) with DoEvents then it does get displayed.
I thought the whole point of executing on separate threads was that I didn't
need DoEvents anymore. Have I missed something?
TIA
Charles