I need help with my program. So I have com port connection ( gps device ) and when the program starts I want to be able to show Form2 until gps eventhandler gets triggerd. And same thing when device starts to send me data, there is some time when device is not available to give me data. How can I know in that time that I need to show again Form2?
This is a bit complicated to explain.
Here is what I have done so far. So when Form1 loads I am showing a Form2 screen which basically says that I am waiting for signal to shown up. Now how can I put this in some sort of loop or something like that which will be always checking for eventhandler to be triggerd and in mean time I am showing this form2.
If you need more explanation let me know.
So here is the code:
private void Form1_Load(object sender, EventArgs e)
{
//open the com port when loading form
comport.Open();
Form2 my_form2 = new Form2();
my_form2.ShowDialog();
}
This is the event handler for GPS signal:
GPS.PositionReceived += new NmeaInterpreter.PositionReceivedEventHandler(GPS_PositionReceived);
And this is GPS function:
private void GPS_PositionReceived(string Lat, string Lon)
{
arrLon = Lon.Split(new char[] { '°', '"' }, StringSplitOptions.RemoveEmptyEntries);
dblLon = double.Parse(arrLon[0]) + double.Parse(arrLon[1], new System.Globalization.NumberFormatInfo()) / 60;
deciLon = arrLon[2] == "E" ? dblLon : -dblLon;
//some more code
}