Click here to Skip to main content
15,924,367 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert tm to time_t Pin
Maxwell Chen10-May-02 0:26
Maxwell Chen10-May-02 0:26 
GeneralRe: Convert tm to time_t Pin
Pete Bassett10-May-02 1:39
Pete Bassett10-May-02 1:39 
QuestionSpin Button?? Pin
9-May-02 23:39
suss9-May-02 23:39 
AnswerRe: Spin Button?? Pin
Maxwell Chen9-May-02 23:43
Maxwell Chen9-May-02 23:43 
AnswerRe: Spin Button?? Pin
Prem Kumar10-May-02 4:04
Prem Kumar10-May-02 4:04 
GeneralProbelm in rich edit view Pin
SamirSood9-May-02 23:21
SamirSood9-May-02 23:21 
QuestionBizTalk Mapper-like Rubberband Control available? Pin
Uwe Keim9-May-02 23:18
sitebuilderUwe Keim9-May-02 23:18 
GeneralThread Message Pin
Hesham Amin9-May-02 23:02
Hesham Amin9-May-02 23:02 
Hi..
I write a miltithreaded MFC application so a worker thread

performs a lengthy operation.

I want the worker thread to notifty the UI thread when it

finishes the operation. So I use SendMessage()

function.

the code is something like this:

<br />
class CInfo  //to send arguments to the worker thread..<br />
{<br />
public:<br />
	HWND hwnd;<br />
//other class members..<br />
}<br />


In the dialog class :


<br />
//member variables:<br />
private:<br />
	CWinThread* m_pThread;<br />
	CInfo info;<br />
<br />
//a push button click event handler:<br />
void CMyDlg::OnStartWorkerBtn()<br />
{<br />
	info.hwnd=this->m_hWnd;<br />
	m_pThread=AfxBeginThread(CWorker::Work,&info,<br />
	THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);<br />
<br />
	m_pThread->m_bAutoDelete=FALSE;<br />
	m_pThread->ResumeThread();<br />
}<br />
<br />
//handler of the user message sent from worker thread:<br />
void CMyDlg::OnWorkerMessage()<br />
{<br />
	//perform some operations int the UI..<br />
}<br />


The worker thread code:
<br />
UINT CWorker::Work(void* arg)<br />
{<br />
	CInfo* info=(CInfo*)arg;<br />
	<br />
	// perform the lengthy operation:<br />
	/*<br />
	.....<br />
	*/<br />
	<br />
	SendMessage(info->hwnd,WM_USER+1,0,0);<br />
}<br />


The code works fine in the debug version but an ( Access

violation ) error occures in the release version when the UI

thread receives the message while dragging the window with the

mouse.

can any one help with that?
GeneralRe: Thread Message Pin
jan larsen9-May-02 23:40
jan larsen9-May-02 23:40 
GeneralRe: Thread Message Pin
Hesham Amin10-May-02 1:58
Hesham Amin10-May-02 1:58 
GeneralRe: Thread Message Pin
Philip Patrick9-May-02 23:49
professionalPhilip Patrick9-May-02 23:49 
GeneralRe: Thread Message Pin
Hesham Amin10-May-02 1:56
Hesham Amin10-May-02 1:56 
GeneralYou are welcome Pin
Philip Patrick10-May-02 3:20
professionalPhilip Patrick10-May-02 3:20 
Generala simple c++ question about operator= Pin
denkor9-May-02 22:55
denkor9-May-02 22:55 
GeneralRe: a simple c++ question about operator= Pin
Maxwell Chen9-May-02 23:06
Maxwell Chen9-May-02 23:06 
GeneralRe: a simple c++ question about operator= Pin
Christian Graus9-May-02 23:07
protectorChristian Graus9-May-02 23:07 
GeneralRe: a simple c++ question about operator= Pin
Maxwell Chen9-May-02 23:16
Maxwell Chen9-May-02 23:16 
GeneralRe: a simple c++ question about operator= Pin
Niklas L12-May-02 21:54
Niklas L12-May-02 21:54 
GeneralAnd copy constructor issue...... Pin
Maxwell Chen9-May-02 23:11
Maxwell Chen9-May-02 23:11 
GeneralThank you ,Maxwell Chen and Christian Graus ! Pin
denkor10-May-02 0:48
denkor10-May-02 0:48 
GeneralRe: Thank you ,Maxwell Chen and Christian Graus ! Pin
Maxwell Chen10-May-02 0:54
Maxwell Chen10-May-02 0:54 
QuestionHow to hide and/or disable PropertyPage Pin
Eugene Pustovoyt9-May-02 22:07
Eugene Pustovoyt9-May-02 22:07 
AnswerRe: How to hide and/or disable PropertyPage Pin
Tom Archer9-May-02 22:28
Tom Archer9-May-02 22:28 
GeneralRe: How to hide and/or disable PropertyPage Pin
Eugene Pustovoyt9-May-02 23:56
Eugene Pustovoyt9-May-02 23:56 
GeneralRe: How to hide and/or disable PropertyPage Pin
Tom Archer10-May-02 5:45
Tom Archer10-May-02 5:45 

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.