private async void DoSomething() { log($"start DoSomething (processresult Thread: {getCurrentThreadInfo()})"); var externalCall = new ExternalCall(3000); var result = await externalCall.LongActionWithError().ConfigureAwait(false); // error will be thrown in Secondary Thread + the Main UI will silently shut down //log($"continue DoSomething (processresult Thread: {getCurrentThreadInfo()})"); }
private async Task <string> processResult() { var externalCall = new ExternalCall(3000); log($"start ExternalCall (processresult Thread: {getCurrentThreadInfo()})"); var result = await externalCall.LongAction().ConfigureAwait(false); // it will throw error, because a secondary Thread will process remaining code (in this function) //log($"ExternalCall returns: {result}. (processresult Thread: {getCurrentThreadInfo()})"); return(result + " (Processed by processresult(). Thread after await externalCall: {getCurrentThreadInfo()})"); }
// primary actions private void DoSync_Click(object sender, RoutedEventArgs e) { LBActionsLog.Items.Clear(); log("DoSync"); logCurThreadInfo(); var externalCall = new ExternalCall(3000); log("start ExternalCall"); var result = externalCall.LongAction().Result; log("ExternalCall result received"); logCurThreadInfo(); }