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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.