Invoking WPF Dispatcher with anonymous method

前端 未结 4 1370
北海茫月
北海茫月 2021-01-17 22:38

I just realized in a C# .Net 4.0 WPF background thread that this doesn\'t work (compiler error):

Dispatcher.Invoke(DispatcherPriority.Normal, delegate()
{
           


        
4条回答
  •  [愿得一人]
    2021-01-17 23:11

    The 'Delegate' class is abstract so you have to provide the compiler with a type that is derived from it. Any class derived from Delegate will do but Action is usually the most appropriate one.

提交回复
热议问题