S
Sakharam Phapale
Hi All,
In following example, while playing file, if thread goes in WaitSleepJoin
state, due to Thread.Sleep method.
Now I want to suspend thread by clicking on cmdSuspend button. I have
written following code, which doesn't suspend it.
Even I tried it by calling m_PlayThread.Interrupt() method which suspends
the thread but cannot resume it again by calling Resume method.
Any kind help will be appreciated.
Thanks and Regards
Sakharam Phapale
----------------------------------------------------------------------------
-----------------------
Private m_IsStop As Boolean
Private sub PlayAudio()
m_IsStop = False
For intLoopCounter = 0 To m_intNoOfFiles
Try
m_objAudioRecorderPlayer.OpenFile(m_arrFiles(intLoopCounter))
m_objAudioRecorderPlayer.StartPlaying(m_lngPlayFromTime,
m_lngPlayToTime)
m_PlayThread.Sleep(lngPlayToTime - lngPlayFromTime)
If m_IsStop Then
m_objAudioRecorderPlayer.CloseFile()
End If
Catch Ex As Exception
m_objAudioRecorderPlayer.CloseFile()
End Try
Loop
End Sub
Private Sub cmdPlay_Click(Sender As Object, ------)
Dim m_PlayThread as New Threading.Thread(AddressOf PlayAudio)
m_PlayThread.Start()
End Sub
Private Sub cmdPause_Click(sender as Object,-------)
m_PlayThread.Suspend()
End Sub
Private Sub cmdResume_Click(--------)
m_PlayThread.Resume()
End Sub
Private Sub cmdStop_Click(--------)
m_IsStop = True
If m_PlayThread.ThreadState = WaitSleepJoin Then
m_PlayThread.Interrupt()
End If
End Sub
In following example, while playing file, if thread goes in WaitSleepJoin
state, due to Thread.Sleep method.
Now I want to suspend thread by clicking on cmdSuspend button. I have
written following code, which doesn't suspend it.
Even I tried it by calling m_PlayThread.Interrupt() method which suspends
the thread but cannot resume it again by calling Resume method.
Any kind help will be appreciated.
Thanks and Regards
Sakharam Phapale
----------------------------------------------------------------------------
-----------------------
Private m_IsStop As Boolean
Private sub PlayAudio()
m_IsStop = False
For intLoopCounter = 0 To m_intNoOfFiles
Try
m_objAudioRecorderPlayer.OpenFile(m_arrFiles(intLoopCounter))
m_objAudioRecorderPlayer.StartPlaying(m_lngPlayFromTime,
m_lngPlayToTime)
m_PlayThread.Sleep(lngPlayToTime - lngPlayFromTime)
If m_IsStop Then
m_objAudioRecorderPlayer.CloseFile()
End If
Catch Ex As Exception
m_objAudioRecorderPlayer.CloseFile()
End Try
Loop
End Sub
Private Sub cmdPlay_Click(Sender As Object, ------)
Dim m_PlayThread as New Threading.Thread(AddressOf PlayAudio)
m_PlayThread.Start()
End Sub
Private Sub cmdPause_Click(sender as Object,-------)
m_PlayThread.Suspend()
End Sub
Private Sub cmdResume_Click(--------)
m_PlayThread.Resume()
End Sub
Private Sub cmdStop_Click(--------)
m_IsStop = True
If m_PlayThread.ThreadState = WaitSleepJoin Then
m_PlayThread.Interrupt()
End If
End Sub