Click here to Skip to main content
15,914,013 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CTreeView / Drawing Question Pin
Igor Sukhov19-Aug-01 9:17
Igor Sukhov19-Aug-01 9:17 
GeneralRe: CTreeView / Drawing Question Pin
19-Aug-01 13:41
suss19-Aug-01 13:41 
GeneralRe: CTreeView / Drawing Question Pin
Paolo Messina20-Aug-01 11:57
professionalPaolo Messina20-Aug-01 11:57 
GeneralWord Add-In Pin
AJ12319-Aug-01 2:07
AJ12319-Aug-01 2:07 
GeneralRe: Word Add-In Pin
Michael P Butler19-Aug-01 4:33
Michael P Butler19-Aug-01 4:33 
GeneralWord Add-In Pin
AJ12319-Aug-01 2:06
AJ12319-Aug-01 2:06 
GeneralRe: Word Add-In Pin
Bret Faller20-Aug-01 8:39
Bret Faller20-Aug-01 8:39 
GeneralWeird thread parameter problem Pin
Christian Skovdal Andersen19-Aug-01 0:20
Christian Skovdal Andersen19-Aug-01 0:20 
I have a ATL class with one member function.

If i invoke a thread from the member function passing the 'this' pointer as the CreateThread() parameter the data is invalid when the parameter is casted back inside the thread function.

A test app demonstrating the problem is available on http://www.codeit.dk/christian/threadtest.zip

Like this

// This is my member function which
// is invoked from within my vb test app
STDMETHODIMP Cxx::yy() {
DWORD dwID=0;

// I put some data into a member variable
m_dwFoo = 200873;
::CreateThread(NULL, 0, _TheThread,
(LPVOID)this, 0, &dwID);
return S_OK;
}

static DWORD WINAPI _TheThread(LPVOID lpv)
{
// Cast the lpv pointer back to a class instance
// (the this pointer)
Cxx* p = (Cxx*)lpv;
// Now p->m_dwFoo is corrupted with an invalid value!!
return 0;
}

If I invoke the thread method from within 'OnFinalConstruct()' everything is peachy. It only happens when it is invoked from within a exposed automation method.

The class is declared a free-threaded in the registry.

Any clues?

Christian Skovdal Andersen
GeneralRe: Weird thread parameter problem Pin
Focht19-Aug-01 10:58
Focht19-Aug-01 10:58 
GeneralRe: Weird thread parameter problem Pin
loket19-Aug-01 12:36
loket19-Aug-01 12:36 
GeneralRe: Weird thread parameter problem Pin
Christian Skovdal Andersen19-Aug-01 20:13
Christian Skovdal Andersen19-Aug-01 20:13 
GeneralRe: Weird thread parameter problem Pin
Patrick_Kutch19-Aug-01 15:40
Patrick_Kutch19-Aug-01 15:40 
GeneralADO simple Connection/Recordset Question II Pin
Christian Graus18-Aug-01 14:22
protectorChristian Graus18-Aug-01 14:22 
GeneralRe: ADO simple Connection/Recordset Question II Pin
Michael Dunn18-Aug-01 20:34
sitebuilderMichael Dunn18-Aug-01 20:34 
GeneralRe: ADO simple Connection/Recordset Question II Pin
Christian Graus18-Aug-01 23:25
protectorChristian Graus18-Aug-01 23:25 
GeneralBefore the system. HELP!!! Pin
The_Server18-Aug-01 13:26
The_Server18-Aug-01 13:26 
GeneralRe: Before the system. HELP!!! Pin
Igor Sukhov19-Aug-01 9:12
Igor Sukhov19-Aug-01 9:12 
Questionfree database? analysis tools? Pin
18-Aug-01 10:12
suss18-Aug-01 10:12 
AnswerRe: free database? analysis tools? Pin
Malcolm McMahon21-Aug-01 4:29
Malcolm McMahon21-Aug-01 4:29 
GeneralRe: free database? analysis tools? Pin
21-Aug-01 5:44
suss21-Aug-01 5:44 
GeneralRe: free database? analysis tools? Pin
21-Aug-01 11:51
suss21-Aug-01 11:51 
AnswerRe: free database? analysis tools? Pin
Steen Krogsgaard21-Aug-01 22:13
Steen Krogsgaard21-Aug-01 22:13 
GeneralConvert Win32 to MFC Pin
18-Aug-01 8:33
suss18-Aug-01 8:33 
GeneralRe: Convert Win32 to MFC Pin
Christian Graus18-Aug-01 14:09
protectorChristian Graus18-Aug-01 14:09 
GeneralRe: Convert Win32 to MFC Pin
Matt Newman20-Aug-01 6:47
Matt Newman20-Aug-01 6:47 

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.