Hello,
I am facing a few issues when handling FSUIPC errors on a simulator crash/freeze. What i do when i receive an error from my FSUIPC thread is:
- Close FSUIPC connection;
- Enter a loop trying to open the connection, once it succeeds, resume the logging method (also runs on a different thread).
The issue is, apparently, that FSUIPCConnection.Close() isn't doing its job. The user reporting this said to me that P3D freezes for a few seconds (30-ish), and then resumes operation. I know the connection isn't being closed because i built a debug version for him and i'm getting this error:
[09:06] FSUIPCBUSY: False // Check that the thread isn't busy
[09:06] UIPCERROR: FSUIPC.FSUIPCException: FSUIPC Error #1: FSUIPC_ERR_OPEN. The connection to FSUIPC is already open.
So, i am thinking about closing the connection every time i try to open it, on my error handler method like this:
private void OpenFSUIPC_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
FSUIPCConnection.Close(); // This will be added to prevent "already open" errors
if (e.Error == null)
{
OpenFSUIPCTimer.Enabled = false; // Once the error is null, disable the open connection timer
FlightTimer.Enabled = true; // Enable the log timer
}
}
My question is, is this the best way to handle the error, is there a problem of successively trying to close the connection without knowing if it is open?
I don't recall the .NET client having a method returning something like "is the connection already open", or i would use that instead.
Maybe i'm being just too much of a perfectionist (i know i am) and trying to do things in the most correct way possible, so i decided to ask here for some advice.
Thank you very much.
Nuno