API Support Forum
OEC API > API Support > The same event into different threads and usage of client in MDI applications
Author Topic: The same event into different threads and usage of client in MDI applications
(3 messages, Page 1 of 1)
Moderators: VPfau
PPietro
Posts: 3
Joined: Jul 21, 2009


Posted: Aug 19, 2009 @ 11:07 AM             Msg. 1 of 3
Hi there,

We are making our software using:
- OECAPICOM v. 3.4.0
- Delphi language
- MDI-form application

What we are doing:
- Every time our software creates a
new module, it loads on it a DLL
which one we pass market name and
Time frame as parameters;

- inside of the DLL, in order to
optimise the code, we use some
threads how many are the values we
want to get from the client: e.g.:
Lastprice, Working orders, etc.

-in one of these threads we manage OnPriceChange
event.

- into DLL we have a private variable
TOECClient type; at OnShow we put the
follow code:

"ourvariableTOECClient" := OECClient
(OECClient is defined into the Host)

....
....

After then, we create the thread to
manage the price-change, putting into
the thread the client as we made from host
to DLL.


All works fine...
but... when we open a second form, which creates
a new istance of the same DLL, that happens:

- the last DLL works and the first one
stop to receive the values.

So then our questions are:

1. Is it correct how we drive the client
from one DLL to another?

2. If yes, where we are wrong?

3. Does It exist a better way to manage
contracts in different instances of the same DLL?

4. We have notice that when two threads are working and
in all of them there's the same event... only one works (the last one...),
the first one is stopped... WHY ?

Best Regards

Pietro Fucci
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Aug 19, 2009 @ 11:11 AM             Msg. 2 of 3
OEC API is intended to use only from the thread where OECClient instance was created. Events are raised to the same thread.
PPietro
Posts: 3
Joined: Jul 21, 2009


Posted: Aug 19, 2009 @ 11:26 AM             Msg. 3 of 3
Thanks for your fast replay, Sergek,
now we are changing our way and we
will let you soon.

Best Regards

Pietro Fucci