I'm an API flake

 

Yep, API has blown a fuse in my head so really could use some pointers from those knowlegable in such things.


It's my continuing battle to have terminal restart itself when it loses connection for an extended period. Sometimes, it just needs a kick to regain connection.


So my IsConnected EA goes something like this...

If connection is lost, start a 5 minute countdown. Re test for connection every 30 seconds and abort countdown if connection is re established.

If after 5 mins there is still no connection open a mirror instance of terminal.

If mirror connects succesfully, it flags itself as alive which triggers original instance to shut itself down passing trading on to mirror.

If mirror does not connect, (ie no alive flag) close mirror and re open until connection is confirmed.

Mirror will now trade as main terminal and if it loses connection will repeat the steps above to swap back to open original terminal and close mirror.


So I have pretty much worked out how to do all that with one exception. Closing the mirror instance if it fails to connect.

From my original instance how do I identify the window handle of the mirror instance? I need this ID to close it from within the original instance EA.


I have looked at

FindWindowA(string lpClassName ,string lpWindowName)

but to be honest I really don't understand what this is. Hopefully this is the right thing, but what do I put as the ClassName and WindowName?

Any help much appreciated

V

 

overkill.

EA notices not connected for 5 minutes. spawns a batch job that kills the terminal (taskkill) and start another.

 
WHRoeder:

overkill.

EA notices not connected for 5 minutes. spawns a batch job that kills the terminal (taskkill) and start another.

It is currently implimented broadly as you suggest but on restart if the new instance fails to connect, the IsConnected fails to initialise so I get stuck with a frozen terminal. This happens often enough to warrant looking for remedies. The only one I can think of is to check I have a connected terminal elsewhere (and therefore IsConnected is running) before killing the original.

Terminal will not always connect when started so I'm guessing I need to shut it down and try again...tbh, I don't know how often when it fails to connect is because of a true connection issue or this phantom "needs a kick issue" maybe if it fails to connect on restart and is just left, it will reconnect when it's ready. Defining the scale of that issue is next to impossible though so thought it wise to just code for the worst case.

Reason: