Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8380431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:27:25+00:00 2026-06-09T16:27:25+00:00

In my application, I have two text boxes accompanied with two labels: Connected and

  • 0

In my application, I have two text boxes accompanied with two labels: “Connected” and “Not Connected”. As seen in my code, if a connection is established, the “Connected” text box will fill with Green, indicating a network connection. It will be red if not.

The functionality of connection detection is working just fine, however, I have to re-open the application for it to detect the change. I am looking for a way to refresh the application every 5-10 seconds or so automatically to detect any change in connectivity. I don’t want to flush out the contents of any other field or box, just the color text boxes. A soft polling loop so to speak. How would I go about doing this using the Timer method. Should I create a new thread in which to run the timer and refresh the box?

Thanks.

  if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == false)
        {
            noConnect.Select();  //if not connected, turn box red
            noConnect.BackColor = Color.Red;

        }

        else
        {
            netConnect.Select();  // if connected, turn box green
            netConnect.BackColor = Color.Lime;

        }

        //need to refresh box/application without losing other box/field contents 
        //in order to constantly check connectivity around 5-10 seconds or so
        //constantly check connectivity 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:27:27+00:00Added an answer on June 9, 2026 at 4:27 pm

    Something like this would work

        public Form1()
        {
            InitializeComponent();
            var timer = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 10000; //10 seconds
            timer.Start();
        }
    
        void timer_Tick(object sender, EventArgs e)
        {
            if (your_function_call())
            {
                netConnect.BackColor = Color.Green;
            }
            else
                netConnect.BackColor = Color.Red;
        }
    

    The timer_Tick would be repeatedly called every interval and you can poll your status and update controls. Because the timer call back is called in the UI-thread you can update any UI elements.

    From Timer Class

    A Timer is used to raise an event at user-defined intervals. This
    Windows timer is designed for a single-threaded environment where UI
    threads are used to perform processing. It requires that the user code
    have a UI message pump available and always operate from the same
    thread, or marshal the call onto another thread. When you use this
    timer, use the Tick event to perform a polling operation or to display
    a splash screen for a specified period of time. Whenever the Enabled
    property is set to true and the Interval property is greater than
    zero, the Tick event is raised at intervals based on the Interval
    property setting.

    This solution uses System.Windows.Forms.Timer that calls the tick on UI-thread. If you use System.Timers.Timer the callback won’t be on UI-thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control in my wp7 application which contains two text boxes
In my application i have two drop down boxes first box had origin second
I have two text boxes and i want to send these two text box
In my application i have 3 edit text boxes ,in that in first two
In my application i have an image button and two text boxes in a
hai all, in my iphone application i have a login view with two text
Application, have a TextBlock and two Buttons, the text is displayed TextBlock by clicking
I have two text boxes I need a functionality like If I am typing
In my application Two edit boxes are there,when clicking appropriate Editbox it will show
I am attempting to write an application in which I have two text fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.