display Hourglass when application is busy

前端 未结 9 1649
说谎
说谎 2020-11-28 03:01

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



        
9条回答
  •  隐瞒了意图╮
    2020-11-28 03:24

    I am simply doing

    Mouse.OverrideCursor = Cursors.Wait;
    try {
        // Long lasting stuff ...
    } finally {
        Mouse.OverrideCursor = null;
    }
    

    According to the documentation of Mouse.OverrideCursor Property

    To clear the override Cursor, set OverrideCursor to null.

    The try-finally statement ensures that the default cursor is restored in any case, even when an exception occurs or the try-part is left with return or break (if inside a loop).

提交回复
热议问题