2013-07-25 62 views
0

我在更新系統托盤應用程序工具提示中的文本時遇到問題。我有一個計時器更新幾個字符串,但它不會更新notifyicon文本。這是我嘗試過的。使用計時器更新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(); 

     } 

回答

0

我刪除了定時器,現在當用戶將鼠標懸停在圖標上時調用每個函數。