I am trying to make a start and pause button (and hence continue) to start, pause, and continue my program. The start button works but the pause button does not. Can someone look at my code and see what the pause button needs to do to pause the
program? I am using VB 2005. Here is my code. Thanks
Imports Microsoft.Win32
Imports System.Threading
PublicClass Form1
Dim m_event As ManualResetEvent = New ManualResetEvent(False)
Dim tw As Thread
PrivateSub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
EndSubPrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'when timer ends Itunes runs and plays a song
Process.Start("Itunes.exe", "c:\Pieces_of_April.mp3")
Timer1.Enabled = FalseMe.Visible = FalseEndEndSubPrivateSub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = TrueThen
Timer1.Enabled = True
Timer1.Interval = 1200000 'clock runs for 20 minutesEndIfEndSubPrivateSub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked = TrueThen
Timer1.Enabled = True
Timer1.Interval = 1800000 'clock runs for 30 minutesEndIfEndSubPrivateSub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
If RadioButton4.Checked = TrueThen
Timer1.Enabled = True
Timer1.Interval = 2700000 'clock runs for 45 minutesEndIfEndSubPrivateSub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
If RadioButton5.Checked = TrueThen
Timer1.Enabled = True
Timer1.Interval = 3600000 'clock runs for 60 minutesEndIfEndSubPrivateSub Form1_FormClosing(ByVal sender AsObject, ByVal e As System.Windows.Forms.FormClosingEventArgs) HandlesMyBase.FormClosing
tw.Abort()
tw.Join()
m_event.Close()
EndSubPrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Start.Text = "Start"
Pause.Text = "Pause"
Pause.Enabled = False
tw = New Thread(AddressOf run)
tw.Start()
EndSubPrivateSub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
m_event.Set()
Start.Enabled = False
Pause.Enabled = TrueIf RadioButton1.Checked = TrueThen
Timer1.Enabled = True
Timer1.Interval = 15000 'clock runs for 15 secondsEndIfEndSubPrivateSub Pause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pause.Click
m_event.Reset()
Pause.Enabled = False
Start.Enabled = TrueEndSubPublicSub run()
Dim CounterCreationData AsInteger = 0
DoWhileTrue
m_event.WaitOne()
Console.WriteLine("executing" & DateTime.Now.ToLongTimeString)
LoopEndSubEndClassThanks
David H.