[DUG] Applicarion.ProcessMessage

Ross Levis ross at stationplaylist.com
Wed Oct 30 14:33:05 NZDT 2013


Except that I can disable the ProcessMessage code and the DLL still functions correctly.  It was added only to resolve the component focus issue.  Without it you couldn’t see which component on the GUI had the focus when tabbing.  So I think it may be the DLL simply occupying the main thread when it starts its work, and I was wrong thinking the messages had something to do with it.

 

Cheers.

 

From: delphi-bounces at listserver.123.net.nz [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Jolyon Smith
Sent: Wednesday, 30 October 2013 8:47 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Applicarion.ProcessMessage

 

It is both.  :) 

 

The processing of any message on the message queue consumes the thread pumping that message queue.

 

The DLL is consuming messages from your message queue but instead of responding to an appropriate message by spawning a separate thread to do the work it requires, it sounds like it is performing that work on the message thread.  The net effect is that your message thread is not “stuck” or “hung” but merely very, very busy, doing the work that the DLL is asking of it.

 

ProcessMessage isn’t “hanging”.  it’s just doing what it’s been asked to do - processing the message.  :)

 

It’s no different than if the server request that the DLL is performing were instead part of an OnClick event on a button in your own app.  The app would “freeze” until the server request has complete.  The only difference here is that the “event handler” is somewhere in side that DLL.

 

 

This is precisely why event response code should always be as efficient as possible.  Ideally you would do all your application work in a separate thread and leave the main thread to be solely responsible for pumping the message queue.  But even then, if you voluntarily offer up control of your message queue thread to an outside DLL, there is always the risk that they will “abuse" the privilege, as appears to be happening in this case.

 

-- 

Jolyon Smith

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20131030/69f2978d/attachment.html 


More information about the Delphi mailing list