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.In terrupt() 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_objAudioRecor derPlayer.OpenF ile(m_arrFiles( intLoopCounter) )
m_objAudioRecor derPlayer.Start Playing(m_lngPl ayFromTime,
m_lngPlayToTime )
m_PlayThread.Sl eep(lngPlayToTi me - lngPlayFromTime )
If m_IsStop Then
m_objAudioRecor derPlayer.Close File()
End If
Catch Ex As Exception
m_objAudioRecor derPlayer.Close File()
End Try
Loop
End Sub
Private Sub cmdPlay_Click(S ender As Object, ------)
Dim m_PlayThread as New Threading.Threa d(AddressOf PlayAudio)
m_PlayThread.St art()
End Sub
Private Sub cmdPause_Click( sender as Object,-------)
m_PlayThread.Su spend()
End Sub
Private Sub cmdResume_Click (--------)
m_PlayThread.Re sume()
End Sub
Private Sub cmdStop_Click(--------)
m_IsStop = True
If m_PlayThread.Th readState = WaitSleepJoin Then
m_PlayThread.In terrupt()
End If
End Sub
----------------------------------------------------------------------------
-------------