Re: Events do not fire when used in COM DLL
From: Bo Berglund (bo.berglund_at_mailbox.swipnet.se)
Date: 11/15/03
- Next message: Joanna Carter \(TeamB\): "Re: Interface aggregation"
- Previous message: Rob Kennedy: "Re: What sense does it make for Release not to clear TForm.Owner?"
- In reply to: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Next in thread: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Reply: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 Nov 2003 08:02:21 +0100
On Fri, 14 Nov 2003 21:37:13 +0100, "Peter Below (TeamB)"
<100113.1101@compuXXserve.com> wrote:
>In article <dpt7rv0ail5etr5oauvslh16lmkp2qg603@4ax.com>, Bo Berglund wrote:
>> Unfortunately the fix did *not* work. It seemed to do so at first but
>> after I tested another way to use it and did a full rebuild it failed.
>> Must be because of a dcu file still lingering on there with the old
>> behaviour. Going back to the first try and rebuilding the program
>> showed that it still does not work. I get the hangs again unless I
>> actually *disable* Syncronize in the communications component.... :-(
>
>The enviroment you are using this in is important. As i said the
>D6DLLSynchronizer will only work if the thread that loads the DLL has a
>message loop. This may be a problem in a COM dll but I don't know if it
>actually is one.
The way it works is this:
Environment = Delphi 7
No runtime packages, all is in the exe file except:
Communication functionality inside a COM dll
Function to call is named XferFiles and takes initialization
parameters as a delimited string.
Processing is all done in XferFiles:
- Create communication object, this creates the serial port component
- Initialize using config string (sets up port, baud etc)
- Execute a sequence of communications command on the object
- Return to main program code
The object itself has built-in handling of commands:
- Compose the string to send to the remote device
- Clear receive buffers
- Send the string out over the serial port
- Enter a wait loop (tried Application.Processmessages and also
tested adding Sleep(1) in that loop).
- Terminate loop on timeout or a flag
- In the OnRxData event of the serial port component the incoming
data are processed.
- When a packet arrives it is detected, extracted and the flag is set
- Now the wait loop exits and the result of the transfer is supplied
to the calling function (XferFiles), which sequences down to the
next command until finished.
What happens is that the OnRxData event never fires, because of the
Synchronize() call inside the serial port component thread. I get the
timeout...
Removing Synchronize makes it work, but I am really uncomfortable with
this since I don't know what is really going on inside the serial port
component.
With this scenario, where is the message loop I should be looking for?
The thread that loads the DLL is a button event in my main
application, and the call to the XferFiles is another button event.
The first button event loads the DLL and brings up a dialogue form.
The second is a button event on that form and fires off the
functionality.
Is it a problem that the dialogue form is shown as a modal form?
/Bo
- Next message: Joanna Carter \(TeamB\): "Re: Interface aggregation"
- Previous message: Rob Kennedy: "Re: What sense does it make for Release not to clear TForm.Owner?"
- In reply to: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Next in thread: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Reply: Peter Below (TeamB): "Re: Events do not fire when used in COM DLL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]