System tray icon with c# Console Application won't show menu

前端 未结 4 1411
名媛妹妹
名媛妹妹 2021-01-02 15:32

I\'ve got a small C# (.NET 4.0) Console Application that I\'d like the user to be able to interact by showing a menu when they right-click the System Tray icon. I can add an

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 16:17

    Here is the solution: You have to use Application.Run() because events of gui in console mode not working. But you can use this solution:

    var task = System.Threading.Tasks.Task.Factory.StartNew(() => ShowTrayIcon());
    
    void ShowTrayIcon()
    {
        some code with tray icon ...
    }
    

    This will start your setup of try icon in new thread ...

提交回复
热议问题