Click here to Skip to main content
15,886,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: "@err,hr" equivalent in VC 2005 Pin
Mohammed Asif Palimar23-Sep-07 18:32
Mohammed Asif Palimar23-Sep-07 18:32 
QuestionHow to retrieve the Child window handle ????? Pin
GauranG Shah17-Sep-07 21:19
GauranG Shah17-Sep-07 21:19 
AnswerRe: How to retrieve the Child window handle ????? Pin
Roger Broomfield17-Sep-07 21:34
Roger Broomfield17-Sep-07 21:34 
GeneralRe: How to retrieve the Child window handle ????? Pin
GauranG Shah17-Sep-07 22:20
GauranG Shah17-Sep-07 22:20 
AnswerRe: How to retrieve the Child window handle ????? Pin
nbugalia17-Sep-07 21:39
nbugalia17-Sep-07 21:39 
GeneralRe: How to retrieve the Child window handle ????? Pin
GauranG Shah17-Sep-07 22:20
GauranG Shah17-Sep-07 22:20 
AnswerRe: How to retrieve the Child window handle ????? Pin
Sreedhar DV17-Sep-07 21:45
Sreedhar DV17-Sep-07 21:45 
Questioninternet help Pin
Karismatic17-Sep-07 19:46
Karismatic17-Sep-07 19:46 
AnswerRe: internet help Pin
Randor 17-Sep-07 20:34
professional Randor 17-Sep-07 20:34 
QuestionIs it possible to get Graphicspath from Region? Pin
Md. Ali Naser Khan17-Sep-07 19:46
Md. Ali Naser Khan17-Sep-07 19:46 
AnswerRe: Is it possible to get Graphicspath from Region? Pin
Russell'17-Sep-07 23:07
Russell'17-Sep-07 23:07 
Questioncan anybody help me out Pin
philiptabraham17-Sep-07 19:20
philiptabraham17-Sep-07 19:20 

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.