PleaseWaitService

Jun 8, 2012 at 3:57 PM

Hi Geert,

would it be possible to make the PleaseWaitWindow changeable (so that i can plugin a telerik Window instead a wpf window...)? Maybe through an IPleaseWaitWindow interface or dynamic method calls?

Thanks!

Jun 9, 2012 at 10:09 AM

Isn't it simpler to write your own PleaseWaitService (it already is an interface) so you can use that instead?

Jun 9, 2012 at 1:35 PM

my idea was to plugin only another derived backend (PleaseWaitWindow) instead of duplicating the functionality of PleaseWaitService, PleaseWaitHelper and most of the PleaseWaitWindow....

Jun 11, 2012 at 8:34 PM

You always could create a custom PleaseWaitService. For instance the "native" telerik control to create the wait service is the RadBusyIndicator. So you could write something like this, registering the current instance of the RadBusyIndicator into the IoC container first. 

public class RadPleaseWaitService : IPleaseWaitService
{
 private readonlyRadBusyIndicator indicator;

 public RadPleaseWaitService(RadBusyIndicator indicator)
 {
  this.indicator = indicator;
 }

 public void Show()
 {
  this.indicator.IsBusy = true;
 }

 public void Show(string status)
 {
  this.indicator.BusyContent = status;
  this.Show();
 }

 public void Show(PleaseWaitWorkDelegate workDelegate, string status)
 {
  this.Show(status);
  var backgrounWorker = new BackgroundWorker();
  backgrounWorker.DoWork += (s, e) => workDelegate.Method.Invoke(workDelegate.Target, null);
  backgrounWorker.RunWorkerCompleted += (s, e) => this.Hide();
  backgrounWorker.RunWorkerAsync();
 }

 public void Show(PleaseWaitWorkDelegate workDelegate, PleaseWaitWorkDelegate callbackDelegate, string status)
 {
  this.Show(status);
  var backgrounWorker = new BackgroundWorker();
  backgrounWorker.DoWork += (s, e) => workDelegate.Method.Invoke(workDelegate.Target, null);
  backgrounWorker.RunWorkerCompleted += (s, e) =>
  {
   this.Hide();
   callbackDelegate.Method.Invoke(workDelegate.Target, null);
  };
  backgrounWorker.RunWorkerAsync();
 }
...

Jun 12, 2012 at 2:13 PM

@alexfdezsauco

thanks for your help. this seems to be a good alternative...