[英]Dispatcher.BeginInvoke Code Paths Error in C#
I am having a problem with a bit of code in a piece of software that I am currently developing. 我正在开发的一个软件中的一些代码有问题。
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
{
AccountSyncOptions getData = new AccountSyncOptions(syncProgress, lblStatus, tblLogins, cboFilter, searching, searchString, btnClearSearch);
getData.retrieveLocalData();
getData.retrieveOnlineData();
}), null);
When I put the code above in an error appears which says 'Not all code paths return a value in anonymous method of type 'System.Windows.Threading.DispatcherOperationCallBack. 当我在上面放置代码时,出现错误,提示“并非所有代码路径都在类型为System.Windows.Threading.DispatcherOperationCallBack的匿名方法中返回值。
The signature of the DispatcherOperationCallback
delegate is DispatcherOperationCallback
委托的签名为
public delegate Object DispatcherOperationCallback(
Object arg
)
So you need to return an object from your anonymous method: 因此,您需要从匿名方法返回一个对象:
this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
{
AccountSyncOptions getData = new AccountSyncOptions(syncProgress, lblStatus, tblLogins, cboFilter, searching, searchString, btnClearSearch);
getData.retrieveLocalData();
getData.retrieveOnlineData();
return null;
}), null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.