すべて、失敗ToolStripMenu
を表示するためにを更新したいと思います。SqlConnection
エラーメッセージをしばらくの間timeToWaitMs
(ミリ秒単位で)表示し、しばらくして操作を行った後、UIを正常な状態に更新します。現在私はやっています(いくつかの不必要な詳細は削除されています)
public void ShowErrorWithReturnTimer(string errorMessage, int timeToWaitMs = 5000)
{
// Update the UI (and images/colors etc.).
this.toolStripLabelState.Text = errorMessage;
// Wait for timeToWait and return to the default UI.
Task task = null;
task = Task.Factory.StartNew(() =>
{
task.Wait(timeToWaitMs);
});
// Update the UI returning to the valid connection.
task.ContinueWith(ant =>
{
try
{
// Connection good to go (retore valid connection update UI etc.)!
this.toolStripLabelState.Text = "Connected";
}
finally
{
RefreshDatabaseStructure();
task.Dispose();
}
}, CancellationToken.None,
TaskContinuationOptions.None,
mainUiScheduler);
}
私が抱えている問題は、が表示されるtask.Wait(timeToWaitMs);
原因になっているCursors.WaitCursor
ことです-これは望ましくありません。エラーメッセージを一定期間表示させた後、エラー以外の状態に戻すにはどうすればよいですか?
御時間ありがとうございます。