[prev in list] [next in list] [prev in thread] [next in thread]
List: twsocket
Subject: Re: [twsocket] [TPing] TThreads, TPing, C++ Builder. Fun, Fun, Fun!
From: Wilfried Mestdagh <wilfried () mestdagh ! biz>
Date: 2002-10-30 19:43:40
[Download RAW message or body]
SZ,
Sorry, I can be very incomplets sometime ;-(
It was because of the C syntax ;-)
The MessagePump in my example returns True if WM_QUIT message arrive, so you can for example:
void _fastcall MyThread::Execute(void)
{
// create ICS components as needed
while (!MessagePump())
// here you do other of things
// destroy ICS components
}
Looking at this the function should return False instead of thrue and should have another name, but
that's a logical issue ;-)
--
rgds, Wilfried
http://www.mestdagh.biz
On 30.10.02 20:30 Fastream Technologies wrote
> But where is the loop? Shouldn't there be a loop to handle all messages in
> the queue (if more than one exist)?
>
> Regards,
>
> SZ
>
> ----- Original Message -----
> From: "Wilfried Mestdagh" <wilfried@mestdagh.biz>
> To: <twsocket@elists.org>
> Sent: Wednesday, October 30, 2002 8:57 PM
> Subject: Re: [twsocket] [TPing] TThreads, TPing, C++ Builder. Fun, Fun, Fun!
>
>
>
>>SZ,
>>
>>yes of course:
>>
>>u_8 MessagePump(void)
>>{
>> MSG Msg;
>>
>> if (PeekMessage(&Msg, 0, 0, 0, PM_REMOVE)) {
>> TranslateMessage(&msg);
>> DispatchMessage(&msg);
>> return (Msg.Message == WM_QUIT);
>> }
>> return 0;
>>)
>>
>>--
>>rgds, Wilfried
>>http://www.mestdagh.biz
>>
>>
>>On 30.10.02 18:47 Fastream Technologies wrote
>>
>>
>>>This is a TThread and no window exist. When I want to quit, I set
>>>thread->Terminated = true; and then in the execute part:
>>>
>>>void __fastcall MyThread::Execute(void)
>>>{
>>> while(!Terminated)
>>> {
>>> messagePump();
>>> doSomething... check/write for events via TCrticialSection'ed
>>>variables from/to other threads...
>>> }
>>>}
>>>
>>>The problem is since when no message is sent and thus the message queue
>>
> of
>
>>>the thread is empty messagePump does not return and so I cannot quit the
>>>application! It simply keeps on waiting! Is there any way for me to have
>>
> the
>
>>>below messagePump return immediately when the queue is empty?
>>>
>>>Regards,
>>>
>>>Subzero
>>>
>>>----- Original Message -----
>>>From: "Wilfried Mestdagh" <wilfried@mestdagh.biz>
>>>To: <twsocket@elists.org>
>>>Sent: Wednesday, October 30, 2002 7:18 PM
>>>Subject: Re: [twsocket] [TPing] TThreads, TPing, C++ Builder. Fun, Fun,
>>
> Fun!
>
>>>
>>>
>>>>SZ,
>>>>
>>>>GetMessage block until a message is received. If your ICS component is
>>>
>>>created in the Execute method
>>>
>>>
>>>>then it is threaded code and a hidden window is created in this thread
>>>
>>>context. When a message is
>>>
>>>
>>>>received theh GetMessage whould return.
>>>>
>>>>--
>>>>rgds, Wilfried
>>>>http://www.mestdagh.biz
>>>>
>>>>
>>>>On 30.10.02 17:54 Fastream Technologies wrote
>>>>
>>>>
>>>>
>>>>>Instead of that I put:
>>>>>
>>>>>void __fastcall messagePump(void)
>>>>>{
>>>>> MSG msg;
>>>>> while(GetMessage(&msg,0,0,0) > 0)
>>>>> {
>>>>> TranslateMessage(&msg);
>>>>> DispatchMessage(&msg);
>>>>> }
>>>>>}
>>>>>
>>>>>BUT, the function GetMessage never returns! When I put breakpoints on
>>>>
>>>all
>>>
>>>
>>>>>lines in the above code in my BCB6Pro, all seem to be valid bookmarks
>>>>
>>>from
>>>
>>>
>>>>>IDE but in reality it suffers from never returning GetMessage after I
>>>>
>>>click
>>>
>>>
>>>>>on F8! What might be wrong?
>>>>>
>>>>>Best Regards,
>>>>>
>>>>>SZ
>>>>>
>>>>>----- Original Message -----
>>>>>From: "Francois PIETTE" <francois.piette@overbyte.be>
>>>>>To: <twsocket@elists.org>
>>>>>Sent: Tuesday, October 29, 2002 9:42 PM
>>>>>Subject: Re: [twsocket] [TPing] TThreads, TPing, C++ Builder. Fun, Fun,
>>>>
>>>Fun!
>>>
>>>
>>>>>
>>>>>>>But Francois, in the reverseDNS code you wrote for me, you USED
>>>>>>>Application->ProcessMessages()!!
>>>>>>
>>>>>>Working in a thread ? I don't think so. If yes, I was tired that
>>>>>
> day...
>
>>>>>>--
>>>>>>francois.piette@overbyte.be
>>>>>>http://www.overbyte.be
>>>>>>
>>>>>>
>>>>>>_______________________________________________
>>>>>>To unsubscribe or change your settings for TWSocket mailing list
>>>>>>please goto http://www.elists.org/mailman/listinfo/twsocket
>>>>>>Visit our website at http://www.overbyte.be
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>To unsubscribe or change your settings for TWSocket mailing list
>>>>>please goto http://www.elists.org/mailman/listinfo/twsocket
>>>>>Visit our website at http://www.overbyte.be
>>>>>
>>>>>
>>>>
>>>>
>>>>_______________________________________________
>>>>To unsubscribe or change your settings for TWSocket mailing list
>>>>please goto http://www.elists.org/mailman/listinfo/twsocket
>>>>Visit our website at http://www.overbyte.be
>>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>To unsubscribe or change your settings for TWSocket mailing list
>>>please goto http://www.elists.org/mailman/listinfo/twsocket
>>>Visit our website at http://www.overbyte.be
>>>
>>>
>>
>>
>>_______________________________________________
>>To unsubscribe or change your settings for TWSocket mailing list
>>please goto http://www.elists.org/mailman/listinfo/twsocket
>>Visit our website at http://www.overbyte.be
>
>
>
> _______________________________________________
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
>
_______________________________________________
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic