今天写winform的时候遇到一个问题,提示:

无法将 lambda 表达式 转换为类型“System.Delegate”,因为它不是委托类型,

主要是为了在子线程中更新UI线程,在wpf中同样的写法不会出现这个问题。

this.Invode(() => 
{
    xxx
});

对于Control.Invoke()来说,可以接收ThreadStart和MethodInvode两种方法,必须要指定执行的方法。可以更改为如下代码:

this.Invode(new MethodInvoker(() => 
{
    xxx
}));

 

相关文章:

  • 2021-11-12
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2021-07-19
  • 2022-12-23
  • 2021-08-16
  • 2021-06-29
相关资源
相似解决方案