Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am working in windows application using c#4.0, In my application there is a button "preview" which showing the preview of reports. Now the issue is that when i am pressing this button report is taking time to generate. Now i want to show a waiting message with waiting cursor? Please help me...
Posted
Updated 16-Jun-11 1:41am
v2

Please see my safe solution based on IDisposable and "using":
Hourglass Mouse Cursor Always Changes Back to its Original Image. How?[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 16-Jun-11 17:31pm    
Good link - interesting discussions, my 5
Sergey Alexandrovich Kryukov 16-Jun-11 21:26pm    
Thank you, Espen.
--SA
nit_singh 17-Jun-11 14:02pm    
my 5..thanks
Sergey Alexandrovich Kryukov 18-Jun-11 2:17am    
Thank you very much.
--SA
Hi,
before calling the expensive operation you can set up the cursor via this code:
this.Cursor = Cursors.WaitCursor;

after the operation ends, set it back:
this.Cursor = Cursors.Default;

Regards
 
Share this answer
 
Comments
version_2.0 16-Jun-11 8:01am    
my 5..
Uday P.Singh 16-Jun-11 9:50am    
good one my 5
Sergey Alexandrovich Kryukov 16-Jun-11 14:45pm    
Unsafe! (I voted 4). What if exception is thrown (a known problem)?
Please see my safe solution.
--SA
private void button1_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Use of wait cursor", "Top", MessageBoxButtons.OKCancel);


if (dr==DialogResult.OK)
{
Cursor = Cursors.WaitCursor;

for (int i = 0; i < 1000000000; i++)
{


}

Cursor = Cursors.Default;
}




}
 
Share this answer
 
Comments
Uday P.Singh 16-Jun-11 9:49am    
good one my 5
Sergey Alexandrovich Kryukov 16-Jun-11 14:45pm    
Not quite. Unsafe! (I voted 4). What if exception is thrown (a known problem)?
Please see my safe solution.
--SA
Sudhir Kumar Srivastava lko 21-Jun-11 7:26am    
that was only example, developer can use according to need.
Do like that

private void mnuPreview_Click(...)
{
Cursor = Cursors.WaitCursor;
.
.
.//your logic
.
.
Cursor = Cursors.Default;
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Jun-11 14:45pm    
Unsafe! (I voted 4). What if exception is thrown (a known problem)?
Please see my safe solution.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900