I have a timer which I want to run on a separate thread. Is this the proper way to start the TICK procedure of the timer?
Thanks for any help!
Code:
Thread PBThread;
private void rdoPBBack_CheckedChanged(object sender, EventArgs e)
{
if (this.rdoPBBack.Checked == true)
{
Thread PBThread = new Thread(new ThreadStart(this.tmrPB.Start));
this.tmrPB.Interval = 200;
this.tmrPB.Enabled = true;
PBThread.IsBackground = true;
PBThread.Start();
}
}
private void tmrPB_Tick(object sender, EventArgs e)
{
vblPBSelectedDistance = this.trkPB.Value;
vblPBDistance = CalcDistance(GateLat, GateLon, Latitude, Longitude, "feet");
if (this.vblPBDistance >= this.vblPBSelectedDistance)
{
this.btnEndFlight.Enabled = true;
this.pbcontrol.Value = 3;
this.tmrPB.Enabled = false;
this.trkPB.Enabled = true;
this.rdoPBBack.Enabled = true;
this.rdoPBTailLeft.Enabled = true;
this.rdoPBTailRight.Enabled = true;
this.grpPushback.Visible = false;
this.lblPBDistanceTravelled.Text = "";
}
else
{
this.trkPB.Enabled = false;
this.rdoPBBack.Enabled = false;
this.rdoPBTailLeft.Enabled = false;
this.rdoPBTailRight.Enabled = false;
this.btnEndFlight.Enabled = false;
this.lblPBDistanceTravelled.Visible = true;
this.lblPBDistanceTravelled.Text = vblPBDistance.ToString("F0").PadLeft(3, '0') + " FT";
}
}
Thanks for any help!