Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer control freezing the UI

Status
Not open for further replies.

robUK2

Programmer
Mar 10, 2008
57
0
0
TH
Hello,

CF 3.5 VS 2008

I have a timer control that is being used to do some work. Code below. The timer interval is set for 1 second. However, when the timer is running the UI freezes for a short period.

I understand that the timer control is uses the UI thread, but I didn't think the amount of work was too much to make the UI freeze for short periods.

I couldn't see any server timers for the compact framework.

Any suggestions would be most helpful.

[/code]
//Get the signal strength of the AP that the adapter is currently connected to
private void GetSignalStrength()
{
try
{
//Loop through all the AP nearby and find the one that is currently being connected (Associated)
if (currentAdapter.NearbyAccessPoints.Count > 0)
{
foreach (AccessPoint ap in currentAdapter.NearbyAccessPoints)
{
if (ap.Name == currentAdapter.AssociatedAccessPoint)
{
this.DisplaySignalStrength(ap.SignalStrength.ToString());
//Break out of for loop when the currently connected AP has been found.
break;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

//Display the signal strength by filling the bars depending on
//the strength of the access point.
private void DisplaySignalStrength(string strength)
{
this.pbExcellent.BackColor = Color.Transparent;
this.pbVeryGood.BackColor = Color.Transparent;
this.pbGood.BackColor = Color.Transparent;
this.pbLow.BackColor = Color.Transparent;
this.pbVeryLow.BackColor = Color.Transparent;

switch (strength)
{
case "Excellent":
this.pbExcellent.BackColor = Color.Green;
this.pbVeryGood.BackColor = Color.Green;
this.pbGood.BackColor = Color.Green;
this.pbLow.BackColor = Color.Green;
this.pbVeryLow.BackColor = Color.Green;
break;
case "Very Good":
this.pbVeryGood.BackColor = Color.Green;
this.pbGood.BackColor = Color.Green;
this.pbLow.BackColor = Color.Green;
this.pbVeryLow.BackColor = Color.Green;
break;
case "Good":
this.pbGood.BackColor = Color.Green;
this.pbLow.BackColor = Color.Green;
this.pbVeryLow.BackColor = Color.Green;
break;
case "Low":
this.pbLow.BackColor = Color.Green;
this.pbVeryLow.BackColor = Color.Green;
break;
case "Very Low":
this.pbVeryLow.BackColor = Color.Green;
break;
default:
break;
}
}

//Check the signal strength every 1 second
private void tmrPollAP_Tick(object sender, EventArgs e)
{
this.GetSignalStrength();
}
[/code]
 
Is the backgroundworker object compatiable with CF? if so, then use that object and fire it off inside the timer.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top