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

  • SEARCH
  • Home
  • 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 6870113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:38:35+00:00 2026-05-27T03:38:35+00:00

I have a tray icon that needs to display two icons: If there is

  • 0

I have a tray icon that needs to display two icons:

  1. If there is network connectivity, display a green circle with a check mark
  2. If there isn’t network connectivity, display a red circle with an X

So what I have is:

using System.Net.NetworkInformation;

bool isConnected = NetworkInterface.GetIsNetworkAvailable()

So I’m thinking of starting a new thread or using the background worker progress because the tray icon is a NotifyIcon which is a component so I can’t use:

Form.Invoke(delegate, object[])

to update the icon property of the NotifyIcon class.

My big concern is the polling process: I could write some logic that does:

while (true) 
{
    System.Threading.Thread.Sleep(1000);
    isConnected = NetworkInterface.GetIsNetworkAvailable();
    if (isConnected)
        notifyIcon.Icon = "ConnectedIcon.ico";
    else
        notifyIcon.Icon = "DisconnectedIcon.ico";
}

but I’ve seen a couple of articles that tell me to stay away from Sleep(1000). I can’t seem to find those articles since I didn’t bookmark them. I’m just curious to know why that isn’t a good idea for polling in a thread.

  • 1 1 Answer
  • 1 View
  • 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-05-27T03:38:35+00:00Added an answer on May 27, 2026 at 3:38 am

    You can register an Event on NetworkChange so you are being notified when the status changes:

    NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
    
    void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)  
    {
        if (e.IsAvailable) {
            Console.WriteLine("Network Available");
        } else {
            Console.WriteLine("Network Unavailable");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a VS2008 app that needs to display two notifyIcons in the System
I have a Java app that has an icon in the system tray. How
I am trying to create an application that will have a tray icon only,
I have tray icon and I've attached a menu to it so that when
I have a system tray icon that receives incoming phone calls. When a call
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I have a .net windows forms application that needs to open directly to the
I'm using NotifyIcon (System tray icon) in my WinForms application. I also have a
I have a WinForm program that checks a database for changes, and if there
I have a application that is based out of the system tray. I have

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.