Click here to Skip to main content
15,917,177 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: convert const wchar* to const byte* Pin
CPallini7-Oct-09 0:28
mveCPallini7-Oct-09 0:28 
GeneralRe: convert const wchar* to const byte* Pin
Rakesh57-Oct-09 2:08
Rakesh57-Oct-09 2:08 
GeneralRe: convert const wchar* to const byte* Pin
CPallini7-Oct-09 2:16
mveCPallini7-Oct-09 2:16 
GeneralRe: convert const wchar* to const byte* Pin
Rajesh R Subramanian7-Oct-09 0:29
professionalRajesh R Subramanian7-Oct-09 0:29 
AnswerRe: convert const wchar* to const byte* Pin
KarstenK7-Oct-09 1:24
mveKarstenK7-Oct-09 1:24 
AnswerRe: convert const wchar* to const byte* Pin
David Crow7-Oct-09 3:17
David Crow7-Oct-09 3:17 
GeneralRe: convert const wchar* to const byte* Pin
Rajesh R Subramanian7-Oct-09 3:23
professionalRajesh R Subramanian7-Oct-09 3:23 
GeneralRe: convert const wchar* to const byte* Pin
David Crow7-Oct-09 3:26
David Crow7-Oct-09 3:26 
GeneralRe: convert const wchar* to const byte* Pin
Rajesh R Subramanian7-Oct-09 3:30
professionalRajesh R Subramanian7-Oct-09 3:30 
Questionreg interview.... Pin
thangvel6-Oct-09 21:44
thangvel6-Oct-09 21:44 
QuestionRe: reg interview.... Pin
CPallini6-Oct-09 21:49
mveCPallini6-Oct-09 21:49 
AnswerRe: reg interview.... Pin
Richard MacCutchan6-Oct-09 22:13
mveRichard MacCutchan6-Oct-09 22:13 
AnswerRe: reg interview.... Pin
Rajesh R Subramanian6-Oct-09 22:17
professionalRajesh R Subramanian6-Oct-09 22:17 
AnswerRe: reg interview.... Pin
santhosh-padamatinti7-Oct-09 0:20
santhosh-padamatinti7-Oct-09 0:20 
QuestionMaking a Thread wait and not exit after the controlling function exits Pin
Hari_166-Oct-09 21:29
Hari_166-Oct-09 21:29 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
Code-o-mat6-Oct-09 21:46
Code-o-mat6-Oct-09 21:46 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
CPallini6-Oct-09 21:54
mveCPallini6-Oct-09 21:54 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
Rajesh R Subramanian6-Oct-09 22:05
professionalRajesh R Subramanian6-Oct-09 22:05 
GeneralRe: Making a Thread wait and not exit after the controlling function exits Pin
Hari_166-Oct-09 23:31
Hari_166-Oct-09 23:31 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
Rajesh R Subramanian6-Oct-09 23:39
professionalRajesh R Subramanian6-Oct-09 23:39 
hraman1987 wrote:
m_pThread = AfxBeginThread(RUNTIME_CLASS(CMyUIThread),THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
m_pThread->ResumeThread();
m_pThread->PostThreadMessage(WM_MYTHREADMESSAGE,NULL,NULL);

My question is once the control reaches the end of this function.. i want the control to saty in the function and not exit it..


If that's what you need, then using an UI thread is fundamentally wrong. In an UI thread, by blocking the control within a handler, you will block the thread from processing further messages posted to the message loop.

What you need is a worker thread with a spin loop to check for exit condition.

Go with something like:

volatile BOOL bExit = FALSE;

UINT ThreadFunc(LPVOID pData)
{
  while(bExit == FALSE) //spin condition
  {
     //Thread code here.
  }
  return FALSE;
}

void CMyDialog::OnBeginTask()
{
  AfxBeginThread(ThreadFunc, myData);  //Whatever myData points to should be valid until the thread dies...
}


When you need the thread to die, set bExit to TRUE. That's all you need. Not an UI thread, no need to derive a class from CWinThread.


It is a crappy thing, but it's life -^ Carlo Pallini

QuestionRe: Making a Thread wait and not exit after the controlling function exits Pin
David Crow7-Oct-09 3:21
David Crow7-Oct-09 3:21 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
Rajesh R Subramanian7-Oct-09 3:24
professionalRajesh R Subramanian7-Oct-09 3:24 
GeneralRe: Making a Thread wait and not exit after the controlling function exits Pin
Hari_168-Oct-09 18:28
Hari_168-Oct-09 18:28 
AnswerRe: Making a Thread wait and not exit after the controlling function exits Pin
Rajesh R Subramanian8-Oct-09 19:44
professionalRajesh R Subramanian8-Oct-09 19:44 
QuestionReg Database Pin
thangvel6-Oct-09 21:26
thangvel6-Oct-09 21:26 

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.