我正在尝试从 Parallel.For 中更新 WPF 文本块,但我不能。我使用调度程序,但我想,我做错了。所有的工作首先完成,然后文本块快速迭代更新。这是我的代码:
Parallel.For(0, currentScene.Textures.Count, delegate(int i)
{
TextureObject texture = (currentScene.Textures[i]);
MainWindow.Instance.StatusBarText.Dispatcher.BeginInvoke(new Action(()
=> MainWindow.Instance.StatusBarText.Text = "Loading Texture " + i
+ " - " + texture.Name ), null);
LoadTexture(texture);
}
});