Click here to Skip to main content
15,902,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralEDIT BOX Pin
13-Jul-01 4:43
suss13-Jul-01 4:43 
GeneralRe: EDIT BOX Pin
Daniel Ferguson13-Jul-01 10:45
Daniel Ferguson13-Jul-01 10:45 
GeneralRe: EDIT BOX Pin
1-Oct-01 0:42
suss1-Oct-01 0:42 
GeneralMicrosoft Speech SDK V5.0 Pin
jerry0davis13-Jul-01 4:33
jerry0davis13-Jul-01 4:33 
GeneralListview Tooltip Pin
Anthony988713-Jul-01 4:03
Anthony988713-Jul-01 4:03 
GeneralRe: Listview Tooltip Pin
Derek Price13-Jul-01 5:23
Derek Price13-Jul-01 5:23 
GeneralATL Comm band: a few problems Pin
BigBear13-Jul-01 1:47
BigBear13-Jul-01 1:47 
GeneralRe: ATL Comm band: a few problems Pin
Erik Thompson13-Jul-01 7:22
sitebuilderErik Thompson13-Jul-01 7:22 
Generaltimer Pin
ov12-Jul-01 23:46
ov12-Jul-01 23:46 
GeneralRe: timer Pin
Tomasz Sowinski13-Jul-01 0:49
Tomasz Sowinski13-Jul-01 0:49 
GeneralHow: each doc/view in own thread (advanced) Pin
EiSl12-Jul-01 23:28
EiSl12-Jul-01 23:28 
GeneralRe: How: each doc/view in own thread (advanced) Pin
Tomasz Sowinski12-Jul-01 23:48
Tomasz Sowinski12-Jul-01 23:48 
GeneralRe: How: each doc/view in own thread (advanced) Pin
EiSl13-Jul-01 0:45
EiSl13-Jul-01 0:45 
GeneralRe: How: each doc/view in own thread (advanced) Pin
Tomasz Sowinski13-Jul-01 1:08
Tomasz Sowinski13-Jul-01 1:08 
GeneralRe: How: each doc/view in own thread (advanced) Pin
Tomasz Sowinski13-Jul-01 1:31
Tomasz Sowinski13-Jul-01 1:31 
GeneralRe: How: each doc/view in own thread (advanced) Pin
#realJSOP13-Jul-01 1:41
professional#realJSOP13-Jul-01 1:41 
GeneralRe: How: each doc/view in own thread (advanced) Pin
EiSl13-Jul-01 3:12
EiSl13-Jul-01 3:12 
GeneralRe: How: each doc/view in own thread (advanced) Pin
#realJSOP13-Jul-01 7:29
professional#realJSOP13-Jul-01 7:29 
GeneralRe: How: each doc/view in own thread (advanced) Pin
EiSl15-Jul-01 19:47
EiSl15-Jul-01 19:47 
GeneralRe: How: each doc/view in own thread (advanced) Pin
#realJSOP16-Jul-01 0:29
professional#realJSOP16-Jul-01 0:29 
GeneralRe: How: each doc/view in own thread (advanced) Pin
EiSl16-Jul-01 21:41
EiSl16-Jul-01 21:41 
GeneralRe: How: each doc/view in own thread (advanced) Pin
#realJSOP17-Jul-01 1:53
professional#realJSOP17-Jul-01 1:53 
GeneralRe: How: each doc/view in own thread (advanced) Pin
Stephen C. Steel13-Jul-01 13:11
Stephen C. Steel13-Jul-01 13:11 
I don't think that a thread per doc/view is a good approach: there are a lot of complications, and it doesn't change the fact that only one thread can update the GUI at a time (the GDI calls are serialized).

A much better approach, which I have used successfully in a couple of commercial applications, is to have one worker thread per doc, with the original GUI thread handling all the views. The worker threads can update each documents contents to reflect the input recieved via TCP/IP independently.

You can run into some problems invoking window related functions from a worker thread because of the need to link C++ objects like CWnds with the associated Windows HWND (look up handle maps in the VC++ docs if you want the messy details). As long as the worker threads stick to updating the data in the CDocument derived class, you won't have problems. You may have to use critical sections or some other form of synchronization to stop the GUI thread from reading partially updated document contents though.

I get around the handle map problem by defining a user message UM_UPDATE_VIEWS. The worker threads POST (not send) this message to the main window after changing the document contents. The main GUI thread processes this message, by calling CDocument::UpdateAllViews() for the CDocument derived object passed as a pointer in the LPARAM. This way UpdateAllViews() gets invoked by the main GUI thread, so there is no problem with handle maps.



Stephen C. Steel
Kerr Vayne Systems Ltd.
GeneralCOleDateTime Pin
12-Jul-01 23:19
suss12-Jul-01 23:19 
GeneralRe: COleDateTime Pin
markkuk13-Jul-01 8:12
markkuk13-Jul-01 8:12 

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.