Profile Picture

Broker plugin enter twice INITIALIZE function

Posted By gbulle 8 Years Ago
Message
Posted Wednesday April 29 2009
Hi,

when I click "Live Options"  the datafeed plugin start fine and collect data

When I see data arriving I click on "Start Live System" and

the broker plugin enter into initialize function (checked with debugger);just after having entered

into initialze function I  see a dialog with "loading system step 4/6".... and then again (at setp 4) the plugin enter into initialize function.

The same If I click directly "Start Live System"  having not previously clicked "Live Options"

Why? What wrong?

Bye

GB

Posted Wednesday April 29 2009
Let me see if I understand correctly. If you start live data manually, you have 1 entry into Connect. Then after you see data coming in, you click Start Live System and you see 2 more calls to Connect which means 3 total calls to connect. Is this correct? Also, have you set a breakpoint on Disconnect? Is that ever called before the 2 additional calls to Connect?

gbulle (4/29/2009)
Hi,

when I click"Live Options"the datafeed plugin start fine and collect data

When I see data arriving I click on "Start Live System" and

the broker plugin enter into initialize function (checked with debugger);just after having entered

into initialze function I see a dialog with "loading system step 4/6".... and then again(at setp 4)the plugin enter into initialize function.

The same If I click directly "Start Live System" having not previously clicked "Live Options"

Why? What wrong?

Bye

GB
Posted Wednesday April 29 2009
Be aware: Not CONNECT.... INITIALIZE!!

I am sure .. the plugin enter INITIALIZE and then CONNECT (NO the inverse!!)

No DISCONNECT at all (never my debug break hit into disconnect function)

I have two different DLLs (one for datafeed and another one for broker ) where

MultipleInstance flag is FALSE

The datafeed plugin work fine (I enter once in initalize and then connect)

The broker plugin enter once.... than after "System progress step 4/6" enter the second time; no DISCONNECT;

after the first run it appear the broker plugin is working fine (no error message).... but the second run breaks all things.

If I click directly "LIVE SYSTEM: we have

1- INITIALIZE/CONNECT of broker plugin (first run)

2- again INITIALIZE/CONNECT of broker plugin (second run)

3- INITIALIZE/CONNECT of  datafeed (first run)

Bye

GB

Posted Wednesday April 29 2009
Yes, Initialize will be called an extra time.  The plugin is initialized before starting a live system to check if it is a live broker (by calling IBroker.IsLiveBroker).  If it is, RightEdge will display a warning dialog about live trading (unless you've turned that warning off).

After the trading AppDomain is created and the system is initialized, RightEdge will then create and initialize the instance of the broker plugin that will be used.

We could modify RightEdge to avoid the first call to Initialize.  However, I don't think that would help you much, as the second call to initialize is followed immediately by a call to Connect.  It seems that you were trying to use Initialize as a way of starting the connection process earlier to speed things up, but if Connect is called immediately after Initialize that won't help you much.

Thanks,
Daniel

Posted Wednesday April 29 2009
The init process of my functions is async so that I will use 

 Manualreset Event  (Bill's suggestion) to syncronize my functions with your functions

and I will stop into CONNECT waiting for  my functions to terminate the init process

So, if it is possible to have only one call... good  otherwise please how

to I know it is the first time so that I can eventually skip the initialitation

phase and do the initialitazion in the second run?

I do not like flags based on disk files, and a variable as flag is not persistent I suppose (may be a shared variable?)

Bye

GB

Posted Wednesday April 29 2009
Now, in the first run,  you  do not call  disconnect....

.. if you  during  the first run call DISCONNECT..

it is not an elegant solutions but probably works

because I connect/disconnect and again I connect/disconnect

Bye

Posted Thursday April 30 2009
RightEdge doesn't call the Disconnect method if it hasn't called the Connect method. The initialize method isn't meant to be used to start a connection.  Can you change your plugin so that it starts the init/connect process in the Connect method and waits for it to complete before returning?  This is really how it is supposed to work.

Does this make sense?

Thanks,
Daniel

Posted Thursday April 30 2009
Hi

I remember the story;

I moved my init functions from Connect to Initialize because of this error:

Cannot pass a GCHandle across AppDomains

When my init function are into Initialize I do not see this error but I have other problems.

So I have to fix the "Cannot pass a GCHandle across AppDomains" raised by low level DLL

written in C++;

The datafeed alone works fine; datafeed+broker plugin have this issue (Cannot pass a GCHandle across AppDomains)

so I suppose it is not possible to share the same low level DLLs;

I have:

broker_plugin.dll (.net)--->  fix.dll (.net)  --> low_level_dll (C++)

datafeed_plugin.dll (.net)---> fix.dll (.net) --> low_level_dll (C++)

Please have you a suggestion on how two have separated instances without doing too much work (just to test this idea)?

I have verified that RightEdge loads  plugin's dlls into GAC

can I move low_level dlls  from plugin directory into other directories?

TX

Bye

GB


Edited: Thursday April 30 2009 by gbulle
Posted Thursday April 30 2009
I'm pretty sure if we make the change so that Initialize is only called once, then you will start getting the "Cannot pass GCHandle across AppDomains" error.  The first time we call Initialize it is in the main AppDomain, but we would remove this so your code would be running in the system AppDomain as it was when you had all the code in Connect.

Is the fix.dll written by you?  If so, you may be able to fix the problem.  Here is a post explaining the problem and how to solve it: http://lambert.geek.nz/2007/05/29/unmanaged-appdomain-callback/

If you don't have the code for the fix.dll, I think the only solution may be to use a service proxy.  You would write a stand alone app which would look like this:

ServiceProxy.Exe -> fix.dll -> low_level_dll

You would write a RightEdge plugin that would communicate with the service proxy via sockets.  It wouldn't directly reference the fix.dll.

Thanks,
Daniel

Posted Thursday April 30 2009
Hi,

I am evaluating the effort to do...

I would like to understand one think with your help:

1- no "app domain" error  in my datafeed plugin (the init process is the same of the broker plugin)

2- only into borker plugin I see this error just after the login event

Ther  is a difference at app domain level between the plugins?

Can you send me the piece of code that creates the appdomain and load the dlls?

(I want to  replicate the error creating an EXE that mimic your logic)

Bye

GB



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems