Click here to Skip to main content
15,889,096 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help !! Pin
ThatsAlok18-May-05 18:12
ThatsAlok18-May-05 18:12 
GeneralRe: Help !! Pin
Sreekanth Muralidharan18-May-05 18:15
Sreekanth Muralidharan18-May-05 18:15 
GeneralRe: Help !! Pin
ThatsAlok18-May-05 18:42
ThatsAlok18-May-05 18:42 
GeneralRe: Help !! Pin
Sreekanth Muralidharan18-May-05 19:19
Sreekanth Muralidharan18-May-05 19:19 
GeneralRe: Help !! Pin
ThatsAlok18-May-05 19:25
ThatsAlok18-May-05 19:25 
GeneralRe: Help !! Pin
Sreekanth Muralidharan18-May-05 19:28
Sreekanth Muralidharan18-May-05 19:28 
GeneralRe: Help !! Pin
Sreekanth Muralidharan18-May-05 23:14
Sreekanth Muralidharan18-May-05 23:14 
GeneralRe: Help !! Pin
ThatsAlok18-May-05 23:29
ThatsAlok18-May-05 23:29 
Hi SreeKanth,


Sreekanth Muralidharan wrote:
I think we have become real friends by now
Offcourse


Sreekanth Muralidharan wrote:
How can you write a handler which is called when a thread is terminated?

Let me demonstrate whole logic using above sample code ok!
HANDLE g_hThreadWaitHandle;
CYourDlg { 
public: 
 --- your function---
  --- your variable--- 
BOOL isStop; 
BOOL isPause
}

// let this is function that open recording thread
 // for you

CYourDlg::OnPLAY()
{
  /// as We Playing no need to set Stop and Pause var    this->isStop=FALSE;  
this->isPause=FALSE;

g_hThreadWaitHandle=CreateEvent(0,FALSE,FALSE,"SREEKANTH");

 // Start thread and send current class pointer as     
 // parameter  
AfxBeginThread(&yourWorkerThread,reinterpret_cast(this));
}

CYourDlg::OnPAUSE()
{
  // Play|Pause
  this->isPause!= this->isPause;

}

CYourDlg::OnSTOP()
{
  // Order Thread to Stop
   this->isSTOP= TRUE;
   WaitForSingleObject(g_hThreadWaitHandle,INFINITE);
}


UINT yourWorkerThread(LPVOID lpParam)
{  
 // Cast it back to original  
 CYourDlg *m_Dlg=( CYourDlg *)lpParam;  

// Now Main Loop will check condition for 
 // STOP 
  while(!m_Dlg->isStop) 
 { 
    // Sub Loop for Pause!    
   while(m_Dlg->isPause)      
   Sleep(20);  

  ----Do you reading writing blah blah-------  
 }
 // Notify Main Thread about closure
 SetEvent(g_hThreadWaitHandle);
return 0;
}


"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow


cheers,
Alok Gupta
GeneralRe: Help !! Pin
Sreekanth Muralidharan19-May-05 17:10
Sreekanth Muralidharan19-May-05 17:10 
GeneralRe: Help !! Pin
ThatsAlok19-May-05 20:44
ThatsAlok19-May-05 20:44 
GeneralRe: Help !! Pin
Sreekanth Muralidharan19-May-05 23:17
Sreekanth Muralidharan19-May-05 23:17 
GeneralRe: Help !! Pin
ThatsAlok19-May-05 23:25
ThatsAlok19-May-05 23:25 
GeneralRe: Help !! Pin
Sreekanth Muralidharan20-May-05 17:27
Sreekanth Muralidharan20-May-05 17:27 
GeneralRe: Help !! Pin
ThatsAlok20-May-05 22:21
ThatsAlok20-May-05 22:21 
GeneralRe: Help !! Pin
Sreekanth Muralidharan22-May-05 17:08
Sreekanth Muralidharan22-May-05 17:08 
GeneralRe: Help !! Pin
ThatsAlok22-May-05 17:49
ThatsAlok22-May-05 17:49 
GeneralRe: Help !! Pin
Sreekanth Muralidharan23-May-05 18:33
Sreekanth Muralidharan23-May-05 18:33 
GeneralRe: Help !! Pin
ThatsAlok23-May-05 18:50
ThatsAlok23-May-05 18:50 
GeneralRe: Help !! Pin
Sreekanth Muralidharan23-May-05 20:31
Sreekanth Muralidharan23-May-05 20:31 
GeneralRe: Help !! Pin
ThatsAlok23-May-05 20:35
ThatsAlok23-May-05 20:35 
GeneralRe: Help !! Pin
Sreekanth Muralidharan23-May-05 23:22
Sreekanth Muralidharan23-May-05 23:22 
GeneralRe: Help !! Pin
ThatsAlok23-May-05 23:34
ThatsAlok23-May-05 23:34 
GeneralRe: Help !! Pin
Sreekanth Muralidharan23-May-05 23:24
Sreekanth Muralidharan23-May-05 23:24 
GeneralRe: Help !! Pin
ThatsAlok23-May-05 23:33
ThatsAlok23-May-05 23:33 
GeneralRe: Help !! Pin
Sreekanth Muralidharan29-May-05 22:53
Sreekanth Muralidharan29-May-05 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.