【发布时间】:2012-08-31 22:28:58
【问题描述】:
我正在开发一个 WPF 应用程序,我只是想在任务运行之前和之后更改光标。我有这个代码:
this.Cursor = Cursors.Wait;
Task.Factory.StartNew(() => PerformMigration(legacyTrackerIds)).ContinueWith(_ => this.Cursor = Cursors.Arrow);
光标确实会变为等待光标,但在任务完成后不会变回箭头。如果我在 ContinueWith() 方法中放置一个断点,它就会被命中。但光标不会变回箭头。为什么?
这是我尝试的旧方法。光标变回箭头,但我不想 Wait() 完成任务。
this.Cursor = Cursors.Wait;
Task.Factory.StartNew(() => PerformMigration(legacyTrackerIds)).Wait();
this.Cursor = Cursors.Arrow;
【问题讨论】: