HondaCop Posted April 12, 2008 Report Posted April 12, 2008 Hello Peter, I have been using your .NET DLL sample (1.3) for C# and I was wondering how can it be coded so that if for some reason the application loses the connection to FSUIPC, it can reopen a new connection and continue functioning as if nothing happened? catch (FSUIPCException ex) { if (ex.FSUIPCErrorCode == FSUIPCError.FSUIPC_ERR_SENDMSG) { // Send message error - connection to FSUIPC lost. // Show message, disable the main timer loop and relight the // connection button: // Also Close the broken connection. FSUIPCConnection.Close(); MessageBox.Show("The connection to Flight Sim has been lost.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { // not the disonnect error so some other baddness occured. // just rethrow to halt the application throw ex; } } The code above is the catch that detects when the connection is lost. How can I edit it, so that it just attempts to open a new connection and continue functioning normally? Thanks for any help...
Pete Dowson Posted April 12, 2008 Report Posted April 12, 2008 Hello Peter,I have been using your .NET DLL sample (1.3) for C# Not mine. I'm afraid I don't know C# at all. It doesn't look anything like C or C++, and I don't like "managed" languages at all, too much stuff between me and what I want to do. The code above is the catch that detects when the connection is lost. How can I edit it, so that it just attempts to open a new connection and continue functioning normally? Can't you just try opening again? The C code I supply (the source for the library) actually does lots of retries in any case, over a period of many seconds. Of course you don't want to hang the PC -- if you take the processor then FSUIPC, running in a different process, won't be getting time to respond and connect in any case. It is only a Message it is looking for, but you have to allow time for that. So, the normal way would be to continue to attempt to connect on some sort of Timer message from Windows, sleeping (relinquishing the processor) in-between times. You could display a little amodal dialogue saying "trying to connect ..." with an "Abort" button too. Regards Pete
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