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 6922567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:25:22+00:00 2026-05-27T10:25:22+00:00

I have an application that runs a new thread to show a taskbar icon.

  • 0

I have an application that runs a new thread to show a taskbar icon. Now I just can’t figure out how I can call the TaskbarIcon (this is created on the new thread) from my main thread to show a balloon tip.

The code I have right now is:

public class NotificationHelper
{
    private TaskbarIcon notifyIcon { get; set; }

    public NotificationHelper()
    {
        Thread thread = new Thread(OnLoad);
        thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
        thread.Start();
    }

    public void ShowNotification(string text)
    {
        notifyIcon.ShowBalloonTip("Demo", text, notifyIcon.Icon);
    }

    public void OnLoad()
    {
        notifyIcon = new TaskbarIcon();
        notifyIcon.Icon =
            new Icon(@".\Icon\super-man-icon.ico");
        //notifyIcon.ToolTipText = "Left-click to open popup";
        notifyIcon.Visibility = Visibility.Visible;

        while (true)
        {
            Thread.Sleep(1000);
        }
    }

    private void ShowBalloon()
    {
        notifyIcon.ShowBalloonTip("Demo", Message, notifyIcon.Icon);
    }
}

And when I try to call ‘ShowNotification(“foobar”);’ I get this exception:

Object reference not set to an instance of an object.

The reason why I have ‘while(true){}’ in ‘Onload()’ is that I need the thread to be running until I close my application.

  • 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-05-27T10:25:23+00:00Added an answer on May 27, 2026 at 10:25 am

    In your main thread, create a dispatcher with:

    Dispatcher dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
    

    Pass it to your NotificationHelper:

    Dispatcher FDispatcher;
    
    public NotificationHelper(Dispatcher ADispatcher)
    {
         FDispatcher = ADispatcher;
         //...
    }
    

    Show the balloon:

    private void ShowBalloon()
    {
        FDispatcher.invoke(new Action(() => {
            notifyIcon.ShowBalloonTip("Demo", Message, notifyIcon.Icon);
        }));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multithreaded application that runs using a custom thread pool class. The
I have an application that runs transactions spanning over multiple databases on the same
We have an application that runs over load balanced server instances, and therefore is
I have an application that runs on Windows Mobile 6 Professional PDA devices. The
I have an application that runs fine when executed off the server. When clients
I have an application that runs on a terminal. The terminal is registered on
I have an application that runs on a shared hosting website - it is
I have an application that runs through the rounds in a tournament, and I
I have an application that runs on a client's server built on a SQL
I have an application that runs the a command as below: <command> <switches> >&

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.