Jump to content
The simFlight Network Forums
gdscei

Application reacting to the simulator?

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • 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.