FlugsimulatorBerlin Posted February 4, 2011 Report Posted February 4, 2011 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
FlugsimulatorBerlin Posted February 4, 2011 Author Report Posted February 4, 2011 Or in simple words, like the wideclient detection "Waiting for Connection" <--> "Connected"
Pete Dowson Posted February 4, 2011 Report Posted February 4, 2011 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
FlugsimulatorBerlin Posted February 6, 2011 Author Report Posted February 6, 2011 Hallo Pete, many tanks for your helpful reply. I choosed the counter var to see, if fsuipc is connected with the sim. Also with the multithread i have to think about carefully again Greetings Henning
Paul Henty Posted February 6, 2011 Report Posted February 6, 2011 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
FlugsimulatorBerlin Posted February 6, 2011 Author Report Posted February 6, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now