Re: Pass object from worker thread to main thread
- From: "Steve" <steve@xxxxxxxxx>
- Date: Thu, 20 Oct 2005 23:39:15 GMT
"David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
news:O9xdrma1FHA.3720@xxxxxxxxxxxxxxxxxxxxxxx
> Inline:
>
> Steve wrote:
>
>> "David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
>> news:%23TyRcBa1FHA.1740@xxxxxxxxxxxxxxxxxxxxxxx
>>
>>>Steve:
>>>
>>>You can make a pointer of it and put it in the wParam or lParam (and cast
>>>it back in the receiving function). But you need to think very carefully
>>>about object lifetimes when you do this (the thread function keeps on
>>>running after it does the PostMessage()).
>>
>>
>> Can I not return a copy of new_patient to the dialog class and work with
>> that?
>
> Yes, but you have to return a pointer, because wParam or lParam are not
> large enough to hold a general object. And you have to return a pointer
> that will not do out of scope. Something like:
>
> WPARAP wParam = (WPARAM) new
> Patient(pDlg->getManager().GetNextPatient());
Big help this example. :)
> [There's a lot of (unnecessary?) object copying going on here]
Yes, it is unnecessary. I'm too new to C++ (and used to Java) to produce
efficient code.
.
- References:
- Re: Pass object from worker thread to main thread
- From: Steve
- Re: Pass object from worker thread to main thread
- From: David Wilkinson
- Re: Pass object from worker thread to main thread
- Prev by Date: Re: insert dialog
- Next by Date: Re: Pass object from worker thread to main thread
- Previous by thread: Re: Pass object from worker thread to main thread
- Next by thread: Re: Pass object from worker thread to main thread
- Index(es):
Relevant Pages
|