![]() ![]() | ||
To suspend a thread's execution, you can use the thread's Suspend method:
NewThread.Suspend()
This just stops the thread's execution until you use the Resume method (see "Resuming Threads" coming up next).
For example, we used the Suspend method in the Threading example discussed in the In Depth section of this chapter; this method was called when the user clicks the "Suspend Counting" button in that example (you can see this example at work in Figure 24.10):
Dim Thread1 As New System.Threading.Thread(AddressOf counter1.Count) ⋮ Private Sub Button5_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button5.Click Thread1.Suspend() End Sub
For more on how this example works, take a look at the discussion in the In Depth section of this chapter.
![]() ![]() | ||