Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: reading a Device dependent bitmap from clipboard ! Pin
John R. Shaw5-Nov-04 13:02
John R. Shaw5-Nov-04 13:02 
GeneralSystemParametersInfo Pin
Archer2825-Nov-04 12:18
Archer2825-Nov-04 12:18 
GeneralRe: SystemParametersInfo Pin
Yulianto.5-Nov-04 18:23
Yulianto.5-Nov-04 18:23 
Generaltry/catch throw to ifstream error Pin
dbslon25-Nov-04 12:07
dbslon25-Nov-04 12:07 
GeneralRe: try/catch throw to ifstream error Pin
Andrew Walker5-Nov-04 14:29
Andrew Walker5-Nov-04 14:29 
Generalhelp:can't use mktyplib Pin
happycpp5-Nov-04 11:44
happycpp5-Nov-04 11:44 
Generalanothere thread call UpdateAllViews() Pin
LeeeNN5-Nov-04 11:05
LeeeNN5-Nov-04 11:05 
GeneralRe: anothere thread call UpdateAllViews() Pin
John R. Shaw5-Nov-04 12:17
John R. Shaw5-Nov-04 12:17 
It has been a while!
Essenualy your thread should not be calling function in you document class. I would sugest you thread safe class (directions in MSDN library) which you allocate and initialize in your document (a ponter to data). Pass a pionter to the data class to your thread and use event signals to inform you when the data has changed. This may require you to use OnTimer() some where to check when an modified event has occured.

MyClass::OnTime()
{
   if( Event happened )
      UpdateAllViews(NULL);
}

MyClass::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
{
    if( pSender != this )
        InvalidateWindow();
}

MyClass::OnPaint(...)
{
    //....
    pDoc->mydata.lock();
    // do drawing
    pDoc->mydata.unlock();
}


Oh well, it should work something like that. You would probably want to maintain to copies of the data one for used by the your updata thread and one that holds a copy of the last update, that way you will not be trying to lock data access every time you need to repaint the data (leads to some unexpected results).

As usual there are some articles at CP on the subject and who knows one of them may have already solve your problem.

I hope this helps a little!

Oh! One last possibility is to use a CMemFile(), they can be share by multiple thread via a handle. By you'll still need a method to determine when the data has changed.

Good Luck!


INTP
GeneralRe: anothere thread call UpdateAllViews() Pin
LeeeNN5-Nov-04 12:35
LeeeNN5-Nov-04 12:35 
GeneralRe: anothere thread call UpdateAllViews() Pin
John R. Shaw5-Nov-04 14:04
John R. Shaw5-Nov-04 14:04 
GeneralRe: anothere thread call UpdateAllViews() Pin
Neville Franks6-Nov-04 0:09
Neville Franks6-Nov-04 0:09 
GeneralRe: anothere thread call UpdateAllViews() Pin
LeeeNN8-Nov-04 6:29
LeeeNN8-Nov-04 6:29 
GeneralLinking In Help File Pin
Grahamfff5-Nov-04 10:45
Grahamfff5-Nov-04 10:45 
GeneralDeleting a character in a text file Pin
Nikhil Wason5-Nov-04 9:29
Nikhil Wason5-Nov-04 9:29 
GeneralRe: Deleting a character in a text file Pin
John R. Shaw5-Nov-04 9:50
John R. Shaw5-Nov-04 9:50 
Questioncan i find out free disk space on a computer on network??? Pin
venadder5-Nov-04 8:35
venadder5-Nov-04 8:35 
GeneralDrawing in a Dialog Pin
sir kaber5-Nov-04 7:47
sir kaber5-Nov-04 7:47 
GeneralRe: Drawing in a Dialog Pin
John R. Shaw5-Nov-04 9:30
John R. Shaw5-Nov-04 9:30 
GeneralRe: Drawing in a Dialog Pin
Anonymous5-Nov-04 11:36
Anonymous5-Nov-04 11:36 
GeneralRe: Drawing in a Dialog Pin
John R. Shaw5-Nov-04 12:34
John R. Shaw5-Nov-04 12:34 
GeneralListView_SortItems Pin
Anonymous5-Nov-04 7:03
Anonymous5-Nov-04 7:03 
General(help) Unicode and text files Pin
necroleak5-Nov-04 6:47
sussnecroleak5-Nov-04 6:47 
GeneralRe: (help) Unicode and text files Pin
peterchen5-Nov-04 23:56
peterchen5-Nov-04 23:56 
GeneralRemoving signature from a dll Pin
wrykyn5-Nov-04 6:03
wrykyn5-Nov-04 6:03 
GeneralOwner Drawn Button Pin
Timothy Grabrian5-Nov-04 5:47
professionalTimothy Grabrian5-Nov-04 5: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.