开发者

Windowsless application, threads and Invoke()

开发者 https://www.devze.com 2023-01-13 06:54 出处:网络
Let\'s suppose I have windowsless application: only NotifyIcon is presented. So I\'ve created the only NotifyIcon that I need. But when I had a Form开发者_C百科1 class I could use form1.Invoke(action)

Let's suppose I have windowsless application: only NotifyIcon is presented. So I've created the only NotifyIcon that I need. But when I had a Form开发者_C百科1 class I could use form1.Invoke(action) to perform actions from another thread. And what should I do now?

UPD: this is an answer: we should Invoke() a menu itself

if (mnuTrayMenu.InvokeRequired)
  mnuTrayMenu.Invoke(action);
else
  action();


As I mentioned in my question, I've solved this with:

    if (mnuTrayMenu.InvokeRequired)
        mnuTrayMenu.Invoke(action);
    else
        action();
0

精彩评论

暂无评论...
验证码 换一张
取 消