【发布时间】:2011-10-11 11:00:55
【问题描述】:
您好,我正在尝试使用具有表达式行为的 TPL 创建缩略图,但我在 File.OpenRead(uriSource) 行尝试访问不同的线程异常。我正在尝试将 UI 线程的参数传递到后台任务的线程中,这会导致我认为的错误......我该如何解决这个问题?
Task.Factory.StartNew(() => RenderThumb(UriSource)).ContinueWith((bs) =>
{....}, TaskScheduler.FromCurrentSynchronizationConext());
private BitmapSource RenderThumb(string uriSource)
{
Stream imageStream = File.OpenRead(uriSource);
...
return bitmapSource;
}
【问题讨论】:
-
我们的水晶球今天似乎出现了故障。你介意用你得到的确切例外来更新你的问题吗?
标签: c# wpf task-parallel-library