Invoke没有正常返回
public static async Task<string> DoGet(string uri){
var boxret = false;
boxret = (bool)Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(
() => boxret = true ));
return string.empty;
}
原始代码是上面,可以正常工作。但是当我将Invoke抽出来作为一个方法之后就会出错。
public static async Task<string> DoGet(string uri){
var boxret =InvokeMsg();
return string.empty;
}
private static bool InvokeMsg(){
var boxret = false;
boxret = (bool)Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(
() => boxret = true ));
}
改为这个代码之后,没有执行到return string.Empty,而是在Application.Current.Dispatcher.Invoke()就报Null reference异常。请问是什么原因呢
谢谢
code