Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[color blue]Imports System.Threading[/color]
[color blue]Private m_Thread as Thread[/color]
[color blue]Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load[/color]
[color green]' Make a new counter object.[/color]
[color blue]Dim new_counter As New Counter(Me)[/color]
[color green]' Make the thread to run the object's Run method.[/color]
[color blue]m_Thread = New Thread(AddressOf new_counter.Run)[/color]
[color green]' Make this a background thread so it automatically
' ends when the form's thread ends.[/color]
[color blue]m_Thread.IsBackground = True
m_thread.Start
Button1.Enabled = False
Button2.Enabled = True
End Sub[/color]
[color blue]Private Sub Button1_Click(ByVal sender as Object, ByVal e As System.EventArgs) Handles Button1.Click
If (m_Thread.ThreadState And ThreadState.Unstarted) <> _
0 Then[/color]
[color green]' The thread has never been started. Start it.[/color]
[color blue] m_Thread.Start()
Else[/color]
[color green]' The thread is paused. Resume it.[/color]
[color blue]m_Thread.Resume()
End If
Button1.Enabled = True
Button2.Enabled = False
End Sub[/color]
[color blue]Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click[/color]
[color green]' Suspend the thread.[/color]
[color blue]Debug.WriteLine("Suspending thread")
m_Thread.Suspend()
Button1.Enabled = False
Button2.Enabled = True
End Sub[/color]