Question

I am having issues updating the text in a tooltip for a system tray application. I have a timer updating several strings, but it will not update the notifyicon text. Here is what I have tried.

//This is in my main
    System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 5000;
            aTimer.Enabled = true;



        }

        private static void OnTimedEvent(object sender, ElapsedEventArgs e)
        {

            ProcessIcon.GetDNS();
            ProcessIcon.GetIP();
            ProcessIcon.getMAC();
                    ProcessIcon.showALL();
                    Fixes.SetNotifyIconText(ni, ProcessIcon.showALL()); //This one will not update, the others update fine. 


        }//End part of my main

//This part is in another class for the notifyicon part.


            public void Display()
        {



            // Put the icon in the system tray and allow it react to mouse clicks.          
            ni.MouseClick += new MouseEventHandler(ni_MouseClick1);
            ni.Icon = new Icon("WhoAmI.ico");
            Fixes.SetNotifyIconText(ni, showALL());
            ni.Visible = true;




            // Attach a context menu.
            ni.ContextMenuStrip = new ContextMenus().Create();

        }
Était-ce utile?

La solution

I removed the timer and now call each function when the user hovers over the icon.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top