What's the difference between InvokeAsync and BeginInvoke for WPF Dispatcher

前端 未结 4 871
庸人自扰
庸人自扰 2020-12-08 13:09

I noticed in .NET 4.5 that the WPF Dispatcher had gotten a new set of methods to execute stuff on the Dispatcher\'s thread called InvokeAsync. Before, .NET 4.5 we had Invoke

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 13:21

    Well, one difference I've noticed is that InvokeAsync has a generic overload that returns a DispatcherOperation as a return value and accepts a Func as its delegate input parameter. Thus, you can retrieve the result of the operation via InvokeAsync in a type-safe way analogous to how you can await the result of a Task.

提交回复
热议问题