Jump to content
The simFlight Network Forums

Application reacting to the simulator?


gdscei

Recommended Posts

I apologise for my lack of knowledge with this type of stuff, and so if anyone can point me in the right direction, that'd be great.

 

I am currently having the problem with FSUIPC and this DLL that, whenever opening the simulator, or the simulator crashing, it also affects my application - for example, during startup of the simulator, I am unable to move the application window around, like it's "hanging" waiting for the simulator.

 

Is there a way to fix this? Do I need to run the "connection" in a seperate thread?

Link to comment
Share on other sites

Do I need to run the "connection" in a seperate thread?

 

 

 

Yes, if you don't like the blocking behaviour on the main UI thread.

 

The DLL was first written about 9 years ago against the .NET 2 framework. Back then multi-threading and async was not as easy as it is now in .NET 4.

 

I'm considering dropping .NET 2 support for the next version. If I do, I can make 'asnyc' versions the IO methods so that it doesn't block the UI thread and you'll be able to use a 'callback' model if you prefer this.

 

But for now, if you're using .NET 2 or above you can use the BackgroundWorker class to call Open() and Process() etc. If you're using .NET 4.0 or above then you can also use the new Task class.

 

The other thing you can do is design your application to minimise the time spent doing things that will potentially block the thread. For example, having a button or menu option that the user can use to connect to FS, rather than having your program automatically looking for a connection until if finds one.

 

Paul

Link to comment
Share on other sites

  • 2 weeks later...

Yes, if you don't like the blocking behaviour on the main UI thread.

 

The DLL was first written about 9 years ago against the .NET 2 framework. Back then multi-threading and async was not as easy as it is now in .NET 4.

 

I'm considering dropping .NET 2 support for the next version. If I do, I can make 'asnyc' versions the IO methods so that it doesn't block the UI thread and you'll be able to use a 'callback' model if you prefer this.

 

But for now, if you're using .NET 2 or above you can use the BackgroundWorker class to call Open() and Process() etc. If you're using .NET 4.0 or above then you can also use the new Task class.

 

The other thing you can do is design your application to minimise the time spent doing things that will potentially block the thread. For example, having a button or menu option that the user can use to connect to FS, rather than having your program automatically looking for a connection until if finds one.

 

Paul

 

Hi Paul,

 

Thanks a lot. Got it working!

Link to comment
Share on other sites

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.