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.Dispat开发者_如何学PythoncherOperationCallback(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.
The signature of the DispatcherOperationCallback
delegate is
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);
精彩评论