471,059 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,059 software developers and data experts.

Why is Second Thread Blocked?

I have a solution with two projects.


Private m_Flagged As Boolean
Private WithEvents m_Project2 As New Project2

Private Sub WaitForFlag()
m_Flagged = False

Do While Not m_Flagged

MessageBox.Show("Event Occurred.")

End Sub

Private Sub FlagEvent(...) Handles m_Project2.EventOccurred
m_Flagged = True
End Sub


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?


Nov 20 '05 #1
0 648

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by djw | last post: by
4 posts views Thread by Dr. J | last post: by
13 posts views Thread by Paul | last post: by
14 posts views Thread by Joe | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.