【发布时间】:2012-09-01 20:59:13
【问题描述】:
我有一个继续处理错误的任务:
var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
var loadTask = Task<List<OrderItemViewModel>>.Factory.StartNew(() =>
{
throw new Exception("derp");
});
var errorContinue = loadTask.ContinueWith(t =>
{
MainViewModel.RemoveViewModel(this);
}, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, uiScheduler);
继续被击中,但几秒钟后我在应用程序中收到此错误:
等待任务也没有观察到任务的异常 或访问其 Exception 属性。结果,未观察到 异常被终结器线程重新抛出。
这与 uiScheduler 有关吗?类似问题的解决方法基本上就是我在做的A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was
【问题讨论】:
标签: .net task-parallel-library task continuations unobserved-exception