Invoking WPF Dispatcher with anonymous method

前端 未结 4 1364
北海茫月
北海茫月 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:22

    I would like to point out even more cleaner code example to Svick's one, after all we all like one liners don't we?

    Dispatcher.Invoke((Action) delegate { /* your method here */ });
    

提交回复
热议问题