Click here to Skip to main content
15,910,787 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: An Multi Thread SDI application Pin
baerten18-Sep-07 0:10
baerten18-Sep-07 0:10 
GeneralRe: An Multi Thread SDI application Pin
Marimuthu.r18-Sep-07 1:19
Marimuthu.r18-Sep-07 1:19 
GeneralRe: An Multi Thread SDI application Pin
Waldermort18-Sep-07 2:34
Waldermort18-Sep-07 2:34 
AnswerRe: An Multi Thread SDI application Pin
Russell'18-Sep-07 0:10
Russell'18-Sep-07 0:10 
AnswerRe: An Multi Thread SDI application Pin
Cliff Hatch18-Sep-07 9:04
Cliff Hatch18-Sep-07 9:04 
QuestionON_COMMAND_EX Pin
Rockone17-Sep-07 22:25
Rockone17-Sep-07 22:25 
AnswerRe: ON_COMMAND_EX Pin
ashukasama17-Sep-07 22:57
ashukasama17-Sep-07 22:57 
GeneralRe: ON_COMMAND_EX Pin
Rockone17-Sep-07 23:20
Rockone17-Sep-07 23:20 
QuestionRe: ON_COMMAND_EX Pin
David Crow18-Sep-07 3:09
David Crow18-Sep-07 3:09 
AnswerRe: ON_COMMAND_EX Pin
Rockone18-Sep-07 16:12
Rockone18-Sep-07 16:12 
QuestionRe: ON_COMMAND_EX Pin
David Crow19-Sep-07 2:40
David Crow19-Sep-07 2:40 
AnswerRe: ON_COMMAND_EX Pin
Rockone19-Sep-07 23:45
Rockone19-Sep-07 23:45 
AnswerRe: ON_COMMAND_EX Pin
Mark Salsbery18-Sep-07 6:14
Mark Salsbery18-Sep-07 6:14 
GeneralRe: ON_COMMAND_EX Pin
Rockone18-Sep-07 16:42
Rockone18-Sep-07 16:42 
Questionbasic issue Mode no value Pin
monsieur_jj17-Sep-07 22:13
monsieur_jj17-Sep-07 22:13 
AnswerRe: basic issue Mode no value Pin
Iain Clarke, Warrior Programmer17-Sep-07 22:38
Iain Clarke, Warrior Programmer17-Sep-07 22:38 
QuestionIssue with pointer initialization in a simple thread Pin
__yash__17-Sep-07 21:56
professional__yash__17-Sep-07 21:56 
AnswerRe: Issue with pointer initialization in a simple thread Pin
Cedric Moonen17-Sep-07 22:18
Cedric Moonen17-Sep-07 22:18 
GeneralRe: Issue with pointer initialization in a simple thread Pin
__yash__17-Sep-07 23:09
professional__yash__17-Sep-07 23:09 
AnswerRe: Issue with pointer initialization in a simple thread Pin
Iain Clarke, Warrior Programmer17-Sep-07 22:45
Iain Clarke, Warrior Programmer17-Sep-07 22:45 
What you can do is to use the LPVOID parameter to hold a pointer to some class.

eg.
HANDLE CMyClass::CreateTheThread ()
{
    m_hThread = CreateThread (MyThreadRoutine, ...., this, ...);
    return m_hThread;
}

DWORD MyThreadRoutine (LPVOID pParam)
{
    CMyClass *pThis = (CMyClass *)pParam;
    ....
    return 0;
}


There are things to be careful of though. You have to ensure that the CMyClass object will last longer than the thread routine. Or at least longer than the thread routine will use it.

And in your routine, you are using CASyncSocket. This class uses asynchronous socket behaviour, and responds to messages from winsock, rather than blocking on them. It does *not* mean that it is thread safe. It *might* be if you only send from one thread, and read on another, but don't assume that. This is why I use pretty raw win32 code in my threads, as MFC is explicitly not thread friendly. I'll use CWnd derived classes for it, but only to get access to the m_hWnd member to post messages back to them.

Iain.



GeneralRe: Issue with pointer initialization in a simple thread Pin
__yash__17-Sep-07 23:22
professional__yash__17-Sep-07 23:22 
Question"@err,hr" equivalent in VC 2005 Pin
Mohammed Asif Palimar17-Sep-07 21:45
Mohammed Asif Palimar17-Sep-07 21:45 
AnswerRe: "@err,hr" equivalent in VC 2005 Pin
prasad_som18-Sep-07 2:10
prasad_som18-Sep-07 2:10 
GeneralRe: "@err,hr" equivalent in VC 2005 Pin
Mohammed Asif Palimar20-Sep-07 17:58
Mohammed Asif Palimar20-Sep-07 17:58 
AnswerRe: "@err,hr" equivalent in VC 2005 Pin
prasad_som20-Sep-07 18:09
prasad_som20-Sep-07 18:09 

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.