Hi.
I want to create a simple program that can read AIRSPEED (for example) and update it in real time.... lets say every 300 ms. The program im writing is in C#, but the principles are all same everywhere.
My problem is - i wrote the program that does excatly what i said but the program flow is wrong i suspect bcause it takes 16000kb of RAM, and while the program runs i cant press any buttons in it since the sand clock is showing as a cursor. Here is the part of the code:
bool result = false; // Return boolean for FSUIPC method calls
int dwFSReq = 0; // Any version of FS is OK
int dwOffset = 0x02BC; // Indicated airspeed memory offset
int dwSize = 4; // Indicated airspeed memory size
int token = 0; // Variable to hold returned token index
int dwResult = 0; // Variable to hold returned results
int loop = 1;
int ias = 0;
public Form1()
{
InitializeComponent();
this.Show();
Fsuipc fsuipc = new Fsuipc();
fsuipc.FSUIPC_Initialization();
result = fsuipc.FSUIPC_Open(dwFSReq, ref dwResult);
do {
this.Refresh();
fsuipc.FSUIPC_Read(dwOffset, dwSize, ref token, ref dwResult);
fsuipc.FSUIPC_Process(ref dwResult);
fsuipc.FSUIPC_Get(ref token, ref dwResult);
ias = dwResult / 128;
Thread.Sleep(300);
SUPDATE(ias);
} while (ias > 40);
fsuipc.FSUIPC_Close();
}
public void SUPDATE(int a)
{
this.label1.Text = a.ToString();
}
PLease tell if my program flow is wrong or maybe i should use someother function instead of Thread.Sleep. How should i do it right?
Thanks in advance, if it is easier for u, u can give me suggestions in C++.
P.S. im not very expirienced in programing but i think sufficient enuf. :)