Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi,

My code below works when I boot P3D and FSUIPC is detected as having connected (the label changes from default red to green).

When I close P3D, the label remains green when I am expecting it to turn red again. 

Any ideas why this happens?

 

 

 

Posted

I pasted it in then deleted it as I couldn't put the cursor above the quote to type my message, then forgot to paste it back! Sorry, here it is:

Quote

  Private Sub fsuipcTimer_Tick(sender As Object, e As EventArgs) Handles fsuipcTimer.Tick

        Try

            FSUIPCConnection.Open()

        Catch
        End Try

        If FSUIPCConnection.IsOpen Then
            fsuipcStatus.BackColor = Color.DarkGreen
        Else
            fsuipcStatus.BackColor = Color.Red
        End If

    End Sub

 

Posted

The DLL thinks the connection is still open because you're not doing any process() calls.

Because of the way FSUIPC works, the DLL can only know that P3D has been closed by trying to talk to it. During a process(), if the sim is not answering then the DLL knows the 'connection' is lost. Only then will the IsOpen flag be set to false. Unless you call Process() there is no attempted communication with P3D.

If you need a good starting point for an application with the automatic connection handling already written, please check out the FSUIPC application templates available on the website...

http://fsuipc.paulhenty.com/#downloads

Even if you don't use them as templates, you can see the best way handle the connection and main program loop by looking at the code.

Paul

 

 

 

 

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.