Jump to content
The simFlight Network Forums

How to check continuously if FS is running


Recommended Posts

Dear all,

i'm writing a application in C#.

I like to check continuously in a seperate thread if WideClient is connected to the flightsimulator and show it in my seperate status bar of the application.

(The seperate thread is nessesary due to time critical routines in my main programm.

I found out that in that seperate thread i can not reopen the fsuipc (FSUIPCConnection.Open) due to the already open connection in my main programm.

But how can i simply check whether the connection to FS is still alive or not?

Thank you and greetings Henning

Link to comment
Share on other sites

I like to check continuously in a seperate thread if WideClient is connected to the flightsimulator and show it in my seperate status bar of the application.

(The seperate thread is nessesary due to time critical routines in my main programm.

I found out that in that seperate thread i can not reopen the fsuipc (FSUIPCConnection.Open) due to the already open connection in my main programm.

That's presumably a restriction imposed by the way the C# interface has been constructed. Multiple connections are possible but the instance number used in generating the memory mapped filename needs to be different for each.

However, having more than one connection doesn't directly help do what you want to do, because once WideFS has connected you will get the data back it last saw.

You could try referring to offset 333C, but 337E might be more reliable. With that you have to see if it changes over time. If not then either the connection is broken, or FS is closed or crashed. But note that it is only updated when FSUIPC can do so -- long delays in FS disk activities could slow it occasionally.

Note that using the same connection in separate threads would necessitate some sort of lockout to prevent one thread corrupting the request data formed by the other. Really you'd be better off having the FSUIPC interface in its own thread, honouring requests flagged from any other threads. If your time critical thread is reading FSUIPC data all the time then just add the additional items there and let your checking thread read the results and apply a timeout for changes.

Regards

Pete

Link to comment
Share on other sites

If you are using my Client DLL (as opposed to the older C# SDK) here is some information about using it in multiple threads:

The FSUIPCConnection class only supports one connection per instance of WideClient.exe.

Once the connection is open you can call into the FSUIPCConnection static class from any thread. The Process() call is thread-safe - if two threads call it at the same time the second is blocked until the process on the first is complete.

By using the offset groups you can process different groups of offsets in different threads at different timing intervals.

Paul

Link to comment
Share on other sites

Thank you Paul,

i used your Library at first later i switched back to the C# Library fsuipc.cs from Scott/Bob. It seems to be that i can really manage multiple threads with its own fsuipc stack within a application.

But the reason why i changed was my problems with <offset> settings and static settings in conjunction with the threading.

Greetings Hennig

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.