Displaying wait cursor in while backgroundworker is running

后端 未结 9 1862
傲寒
傲寒 2020-12-30 03:50

During the start of my windows application, I have to make a call to a web service to retrieve some default data to load onto my application. During the load of the form, I

9条回答
  •  春和景丽
    2020-12-30 04:16

    There are a lot of answers here already but I found another solution that worked for me so I'd figured I list it.

    private void ShowWaitCursor(){
        Application.UseWaitCursor = true; //keeps waitcursor even when the thread ends.
        System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; //Normal mode of setting waitcursor
    }
    
    private void ShowNormalCursor(){
        Application.UseWaitCursor = false;
        System.Windows.Forms.Cursor.Current = Cursors.Default;
    }
    

    I use both in line like this and it seams to work the way I expect all the time. Especially when I want to have a wait cursor showing while a worker is running. Hope this helps anyone else still looking.

提交回复
热议问题