0

我在为系统托盘应用程序更新工具提示中的文本时遇到问题。我有一个更新几个字符串的计时器,但它不会更新 notifyicon 文本。这是我尝试过的。

//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();

        }
4

1 回答 1

0

我删除了计时器,现在当用户将鼠标悬停在图标上时调用每个函数。

于 2013-10-25T03:57:40.650 回答