0

I have been developing the code to customise ms-word application and am getting data from exchange server and displaying it. so till the data comes to ms-word i want to show "busy" hour glass symbol. but after execution goes out from the button handler(fraction of seconds) the busy symbole is loosing.

I have one button called "Receive" in the ms-word customised ribbon, so when i press then busy symbol need to be loaded and till the data comes to ms-word from exchange then the symbol has to be retained.

i am using the following code:-

public class MyCursor : IDisposable
{     
private Cursor _preappCursor;      
public MyCursor ()     
{         
_preappCursor= Mouse.OverrideCursor;          
Mouse.OverrideCursor = Cursors.Wait;     
}      
#region IDisposable Members     
 public void Dispose()     
{         
Mouse.OverrideCursor = _preappCursor;     
}      
#endregion 
} 


using(new MyCursor ()) 
{     
//Receive side bar calls the exchange code here and display in ms-word
} 
H H
  • 263,252
  • 30
  • 330
  • 514
Pardha
  • 395
  • 2
  • 5
  • 12

2 Answers2

1

Are you doing the long running operation on the GUI thread? If so, the GUI might be unresponsive wich will cause UI glitches. So, make sure you are running your long running operation on a background thread.

Erik Öjebo
  • 10,821
  • 4
  • 54
  • 75
0

Use a background worker for retrieving data from exchange server.Encapsulate the functionality in BackgroundWorker_DoWork(). Change your cursor to busy this time and leave it.
When the background worker completes its job, change the cursor back to '_preappCursor'. Encapsulate this functionality in BackgroundWorker_RunWorkerCompleted().
Look into this article for more information about background worker with Wpf.

Hope this will help you.

Sunil
  • 2,885
  • 5
  • 34
  • 41