PleaseWaitService

Jun 8, 2012 at 2: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!

Coordinator
Jun 9, 2012 at 9: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 12: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....

Developer
Jun 11, 2012 at 7: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 1:13 PM

@alexfdezsauco

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