Results 1 to 4 of 4

Thread: Timer control freezing the UI

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Timer control freezing the UI

    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();   
            }
    Last edited by steve_rm; Jun 25th, 2008 at 09:40 PM.
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width