Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Global Variable Question Pin
JSadleir19-Mar-06 13:16
JSadleir19-Mar-06 13:16 
GeneralRe: Global Variable Question Pin
Richard Andrew x6419-Mar-06 13:42
professionalRichard Andrew x6419-Mar-06 13:42 
GeneralRe: Global Variable Question Pin
JSadleir19-Mar-06 14:03
JSadleir19-Mar-06 14:03 
GeneralRe: Global Variable Question Pin
Chris Gao19-Mar-06 13:49
Chris Gao19-Mar-06 13:49 
QuestionCSockets and multithreading Pin
softwaremonkey19-Mar-06 11:06
softwaremonkey19-Mar-06 11:06 
AnswerRe: CSockets and multithreading Pin
Richard Andrew x6419-Mar-06 11:20
professionalRichard Andrew x6419-Mar-06 11:20 
GeneralRe: CSockets and multithreading Pin
softwaremonkey19-Mar-06 11:33
softwaremonkey19-Mar-06 11:33 
GeneralRe: CSockets and multithreading Pin
Richard Andrew x6419-Mar-06 11:47
professionalRichard Andrew x6419-Mar-06 11:47 
When you wake up, here is some reading for you straight from the MSDN Library:


Windows Handle Maps

As a general rule, a thread can access only MFC objects that it created. This is because temporary and permanent Windows handle maps are kept in thread local storage to help maintain protection from simultaneous access from multiple threads. For example, a worker thread cannot perform a calculation and then call a document's UpdateAllViews member function to have the windows that contain views on the new data modified. This has no effect at all, because the map from CWnd objects to HWNDs is local to the primary thread. This means that one thread might have a mapping from a Windows handle to a C++ object, but another thread might map that same handle to a different C++ object. Changes made in one thread would not be reflected in the other.

There are several ways around this problem. The first is to pass individual handles (such as an HWND) rather than C++ objects to the worker thread. The worker thread then adds these objects to its temporary map by calling the appropriate FromHandle member function. You could also add the object to the thread's permanent map by calling Attach, but this should be done only if you are guaranteed that the object will exist longer than the thread.

Another method is to create new user-defined messages corresponding to the different tasks your worker threads will be performing and post these messages to the application's main window using ::PostMessage. This method of communication is similar to two different applications conversing except that both threads are executing in the same address space.

For more information about handle maps, see Technical Note 3. For more information about thread local storage, see Thread Local Storage and Using Thread Local Storage in the Platform SDK.
Questionprinting bitmaps Pin
Waldermort19-Mar-06 8:01
Waldermort19-Mar-06 8:01 
AnswerRe: printing bitmaps Pin
David Crow19-Mar-06 9:04
David Crow19-Mar-06 9:04 
AnswerRe: printing bitmaps Pin
Roger Allen19-Mar-06 12:24
Roger Allen19-Mar-06 12:24 
AnswerRe: printing bitmaps Pin
Hamid_RT19-Mar-06 17:09
Hamid_RT19-Mar-06 17:09 
QuestionWhere is call for DLL within VisStu 6.0 C++ Pin
Robert Palma Jr.19-Mar-06 7:45
Robert Palma Jr.19-Mar-06 7:45 
AnswerRe: Where is call for DLL within VisStu 6.0 C++ Pin
Richard Andrew x6419-Mar-06 7:55
professionalRichard Andrew x6419-Mar-06 7:55 
GeneralRe: Where is call for DLL within VisStu 6.0 C++ Pin
Robert Palma Jr.19-Mar-06 8:11
Robert Palma Jr.19-Mar-06 8:11 
GeneralRe: Where is call for DLL within VisStu 6.0 C++ Pin
Richard Andrew x6419-Mar-06 8:17
professionalRichard Andrew x6419-Mar-06 8:17 
GeneralRe: Where is call for DLL within VisStu 6.0 C++ Pin
Robert Palma Jr.19-Mar-06 8:28
Robert Palma Jr.19-Mar-06 8:28 
QuestionWhy memcpy not correct! Pin
Hongjun Ge19-Mar-06 7:10
Hongjun Ge19-Mar-06 7:10 
AnswerRe: Why memcpy not correct! Pin
Richard Andrew x6419-Mar-06 7:26
professionalRichard Andrew x6419-Mar-06 7:26 
AnswerRe: Why memcpy not correct! Pin
Richard Andrew x6419-Mar-06 7:31
professionalRichard Andrew x6419-Mar-06 7:31 
GeneralRe: Why memcpy not correct! Pin
Hongjun Ge19-Mar-06 16:05
Hongjun Ge19-Mar-06 16:05 
AnswerRe: Why memcpy not correct! Pin
Richard Andrew x6419-Mar-06 7:41
professionalRichard Andrew x6419-Mar-06 7:41 
GeneralRe: Why memcpy not correct! Pin
bob1697219-Mar-06 8:04
bob1697219-Mar-06 8:04 
GeneralRe: Why memcpy not correct! Pin
Richard Andrew x6419-Mar-06 8:14
professionalRichard Andrew x6419-Mar-06 8:14 
GeneralRe: Why memcpy not correct! Pin
bob1697219-Mar-06 8:26
bob1697219-Mar-06 8:26 

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.