Wpf Dispatcher.BeginInvoke委托问题

时间:2014-08-28 17:26:21

标签: wpf windows-phone

在我的WP SignalR应用程序中,我正在使用此代码:

_dataHub.Subscribe("ReceiveMessage").Received += list => App.RootFrame.Dispatcher.BeginInvoke(() => Messages.Add(list[0].ToString()));

但我必须使用类似的代码订阅我的SignalR服务器应用程序。

我试过这个:

 _dataHub.Subscribe("ReceiveMessage").Received += list => Dispatcher.CurrentDispatcher.BeginInvoke(() => Messages.Add(list[0].ToString()));

我有委托问题。有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

如错误所述,您提供lambda表达式而不是委托。像这样使用 Action

_dataHub.Subscribe("ReceiveMessage").Received += list => 
             Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => 
                                         Messages.Add(list[0].ToString())));
相关问题