Hi kenazo,
Public Form1() is the constructor. It's a bit unusual to see this.Show() in the constructor. Rather you should put this in the main program method (public static Main()) after you create your form.
Presumably you have something like
Form1 myForm = new Form1();
after that you should do
myForm.Show();
Alternatively you can do:
Application.Run(myForm);
or
Application.Run(new Form1());
Anyway - to your specific problem:
The application isn't responding because it's in a really tight loop. Thread.Sleep() is still blocking the thread - ie, it's waiting 300ms and then carrying on - it's not allowing other threads to run.
What you should use instead is:
Application.DoEvents();
Which unblocks the thread and allows other windows messages etc to be processed.
But there's a much better way of doing this than creating a continuous loop on the main thread:
On the form designer find the 'Timer' control in the toolbox and drag it onto the form.
It's not a visual component so it appears at the bottom of the form.
This timer allows you to run a method every x milliseconds.
In the properties set the Interval to the number of millisecond - So you want 300.
Then on the events section (click the lightning icon on the top of the properties) double click in the blank space next to 'Tick'.
This will take you to the code and wire up an event handler for you. You will see a new method which will now run every 300ms.
It's probably called:
private void timer1_Tick(object sender, EventArgs e)
Ignore the parameters.
Just write your code in here to get the airspeed back.
At some point in your code need to Enable the timer - by default it won't run.
I suggest enabling it after you have opened FSUIPC because the code in the timer event will crash is it's run before FSUIPC is open.
To achieve this - and some other good practise too - I suggest you setup two more events:
In the form designer click on the (blue) title bar of the form to get the properties/events window to show the properties/events for the form itself.
Then go to the events bit and find:
Load
Again double click in the blank area to the right to make a new event handler. This one will run when the form loads.
In here - do the FSCIPC open stuff and lastly enable the timer.
Timer1.Enabled = true;
(Be sure to move the line
Fsuipc fsuipc = new Fsuipc();
up into the form member variables section so it can be accessed from any method).
Lastly, back to the forms events and make a handler for FormClosing.
Here you can close FSUIPC.
Hope that helps at bit. Everything should run much more smoothly, and with the timer method you won't need to worry about Application.DoEvents() either because the timer is on a different thread anyway.
If you have any questions, just ask.
Paul