For a view constructed using WPF, I want to change the mouse cursor to a hourglass when the application is busy and nonresponsive.
One solution is to add
I used Olivier Jacot-Descombes's solution, it's very simple and working well. thanks. update: it even works well without using a different threads/background worker.
I use it with backgroudworker, mouse cursor looks great when it's busy working and return to normal when the work is done.
public void pressButtonToDoSomeLongTimeWork()
{
Mouse.OverrideCursor = Cursors.Wait;
// before the long time work, change mouse cursor to wait cursor
worker.DoWork += doWorkLongTimeAsync;
worker.RunWorkerCompleted += worker_RunWorkerCompleted;
worker.RunWorkerAsync(); //start doing some long long time work but GUI can update
}
private void worker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
//long time work is done();
updateGuiToShowTheLongTimeWorkResult();
Mouse.OverrideCursor = null; //return mouse cursor to normal
}