Reputation: 2651
I'm trying to show waiting cursor while my application initializes after clicking on exe file. My code is below
public MainWindow(string FileName):this()
{
this.Cursor = Cursors.WaitCursor;
//some init code
}
But cursor does change only for a moment of second. How to change it for the whole period my some init code
executes?
UPD: instantiation of the main window looks like this in Program.cs
mainWindow = new MainWindow(args[0]);
Application.Run(mainWindow);
Upvotes: 2
Views: 17873
Reputation: 61
be sure that your form is Enabled
this.Enabled = true;
this.Cursor = Cursors.WaitCursor;
.....
Upvotes: 0
Reputation: 4611
You can do as given below
//Set the Cursor when app begins
Cursor.Current = Cursors.WaitCursor;
//write your Code here
//Change the Cursor to Default
Cursor.Current = Cursors.Default;
I hope this could help you :-)
Upvotes: 0
Reputation: 1020
Try this
//Set the cursor to appear as busy
Cursor.Current = Cursors.WaitCursor;
---Execute your code-------
//Make the Cursor to default
Cursor.Current = Cursors.Default;
Upvotes: 8
Reputation: 236218
Doing a lot of stuff in form's constructor is not very desired.
Also users will not be very happy watching wait cursor instead of your form. Good practice is to inform user about whats happening in your application. I'd prefer to see form with message Initializing... please wait
instead of thinking that your application has some problems and it just can't start quickly like all other exe
files.
Marek Dzikiewicz suggestion is correct, if you want to leave things as is.
Upvotes: 2