Click here to Skip to main content
15,895,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: help++ Pin
Michael Dunn23-Feb-06 17:40
sitebuilderMichael Dunn23-Feb-06 17:40 
AnswerRe: help++ Pin
ThatsAlok26-Feb-06 18:10
ThatsAlok26-Feb-06 18:10 
Questionhelp c++ Pin
jobits1223-Feb-06 14:50
jobits1223-Feb-06 14:50 
AnswerRe: help c++ Pin
Ryan Binns23-Feb-06 15:00
Ryan Binns23-Feb-06 15:00 
AnswerRe: help c++ Pin
BadKarma23-Feb-06 20:36
BadKarma23-Feb-06 20:36 
AnswerRe: help c++ Pin
ThatsAlok23-Feb-06 21:42
ThatsAlok23-Feb-06 21:42 
QuestionRe: help c++ Pin
David Crow24-Feb-06 3:14
David Crow24-Feb-06 3:14 
QuestionEnding Thread Problems Pin
tbrake23-Feb-06 14:03
tbrake23-Feb-06 14:03 
Hi
I have some Debug and AccesViolation on teminating myThread.

My code looks like:
<br />
class MyAppView : public CScrollView<br />
{<br />
...<br />
   CMax * mMax;   // A class containing a Dialog and a function <br />
                  // that will become a WorkerThread<br />
                  // The dialog is created Dynamic and mMax excists while<br />
                  // the the View excists<br />
<br />
   bool maxbreak; // this is set to true from the View <br />
                  // the WorkerThread should terminate when set to true<br />
<br />
   CWinThread * maxID;  // handle to the workerthread<br />
...<br />
};<br />
<br />
<br />
...<br />
// the workerthread<br />
UINT MaxThread(LPVOID pParam)<br />
{<br />
	CMax* dlg = (CMax*)pParam;<br />
	dlg->max();<br />
	return 0;<br />
}<br />
<br />
...<br />
// calling the workerthread<br />
void MyAppView::MaxStart()<br />
{<br />
maxID = AfxBeginThread(MaxThread, mMax,<br />
THREAD_PRIORITY_IDLE ,0,CREATE_SUSPENDED);<br />
maxID->m_bAutoDelete=TRUE;<br />
maxID->ResumeThread();<br />
}<br />
<br />
...<br />
<br />
void MyAppView::OnKeyDown(UINT ..., UINT ..., UINT ...)<br />
{<br />
  switch (nChar) <br />
  {<br />
    case VK_ESCAPE:<br />
        if(!pauseMax)<br />
        {<br />
           maxbreak = TRUE;<br />
           WaitForSingleObject(maxID,INFINITE);<br />
//           delete maxID;  // polls a AccessViolation<br />
        }<br />
        break;<br />
  }<br />
}<br />
<br />
<br />
...<br />
void CMax::max()<br />
{<br />
 ...<br />
  if(p_View)<br />
  {<br />
    p_View->SendNotifyMessage(...);<br />
  }<br />
  while(... && !maxbreak)<br />
  {<br />
    ...<br />
  }<br />
  if(p_View)<br />
  {<br />
    p_View->SendNotifyMessage(...);<br />
  }<br />
  ...<br />
}<br />
<br />


I hope u understand what i mean otherwise pls ask.

I have 2 questions:

1. setting maxbreak = true ends prozessing imediatly but not the thread this takes a while to end up why and how to change ?

2. why does WaitForSingleObject(...) not wait for termination or how to explain the not working 'delete maxID';

THX
AnswerRe: Ending Thread Problems Pin
Ryan Binns23-Feb-06 14:10
Ryan Binns23-Feb-06 14:10 
GeneralRe: Ending Thread Problems Pin
tbrake23-Feb-06 14:17
tbrake23-Feb-06 14:17 
GeneralRe: Ending Thread Problems Pin
Ryan Binns23-Feb-06 14:50
Ryan Binns23-Feb-06 14:50 
GeneralRe: Ending Thread Problems Pin
Blake Miller24-Feb-06 5:26
Blake Miller24-Feb-06 5:26 
QuestionHow to display the value of a variable in a MessageBox? Pin
vinceher23-Feb-06 10:18
vinceher23-Feb-06 10:18 
AnswerRe: How to display the value of a variable in a MessageBox? Pin
David Crow23-Feb-06 10:31
David Crow23-Feb-06 10:31 
AnswerRe: How to display the value of a variable in a MessageBox? Pin
Stephen Hewitt23-Feb-06 10:45
Stephen Hewitt23-Feb-06 10:45 
GeneralRe: How to display the value of a variable in a MessageBox? Pin
vinceher23-Feb-06 13:27
vinceher23-Feb-06 13:27 
GeneralRe: How to display the value of a variable in a MessageBox? Pin
Stephen Hewitt23-Feb-06 13:34
Stephen Hewitt23-Feb-06 13:34 
GeneralRe: How to display the value of a variable in a MessageBox? Pin
Wim Engberts23-Feb-06 23:21
Wim Engberts23-Feb-06 23:21 
QuestionInfo about Digital image watermarking in the Wavelet transform domain ? Pin
Loay Al Lusi23-Feb-06 9:36
Loay Al Lusi23-Feb-06 9:36 
AnswerRe: Info about Digital image watermarking in the Wavelet transform domain ? Pin
Stephen Hewitt23-Feb-06 19:16
Stephen Hewitt23-Feb-06 19:16 
AnswerRe: Info about Digital image watermarking in the Wavelet transform domain ? Pin
Cool Ju23-Feb-06 20:01
Cool Ju23-Feb-06 20:01 
QuestionSorting items, specifying multiple parameters Pin
Gunn31723-Feb-06 9:25
Gunn31723-Feb-06 9:25 
AnswerRe: Sorting items, specifying multiple parameters Pin
David Crow23-Feb-06 9:35
David Crow23-Feb-06 9:35 
GeneralRe: Sorting items, specifying multiple parameters Pin
Gunn31723-Feb-06 10:15
Gunn31723-Feb-06 10:15 
GeneralRe: Sorting items, specifying multiple parameters Pin
David Crow23-Feb-06 10:30
David Crow23-Feb-06 10:30 

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.