You can use an AutoResetEvent. When you create it the param is True or
False. If it is False then when you do WaitOne it waits. If you create it
with a True param you need to .Reset before you .WaitOne
Imports System.Threadin g
Public Class Form1
Inherits System.Windows. Forms.Form
Private Shared autoReset As New AutoResetEvent( False)
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Thread.CurrentT hread.Name = "GUI Thread"
Debug.WriteLine (Thread.Current Thread.Name & " started")
Dim workerThread As Thread = New Thread(AddressO f DoSomething)
workerThread.Na me = "Worker thread"
workerThread.St art()
Debug.WriteLine (Thread.Current Thread.Name & " about to wait")
autoReset.WaitO ne()
Debug.WriteLine (Thread.Current Thread.Name & " finishing")
End Sub
Private Sub DoSomething()
Dim i As Integer
Debug.WriteLine (Thread.Current Thread.Name & " DoSomething")
For i = 1 To 5
Debug.WriteLine (Thread.Current Thread.Name & " sleeping...")
Thread.CurrentT hread.Sleep(500 )
Next
Debug.WriteLine (Thread.Current Thread.Name & " exit DoSomething")
autoReset.Set()
End Sub
End Class
"scorpion53 061" <Its the end of the world as we know
it@here.com> wrote in
message news:um******** ******@TK2MSFTN GP10.phx.gbl...
I have MS Word operating in a thread other than the main writing a report.
Can I tell the main thread to wait until a particular point (a sub starts)
in another thread before continuing on?