Topics: Questions
Nov 12, 2013 at 12:25 PM

I use the pleasewaitservice. for methods wich needs a little bit of time.
I start the service with wait.Show("MyMessage"); and stop it with wait.Hide();

After the call Hide() the message is no more visible but the background is still dimmed and blured for a short time. The time differes. It belongs to the time of the action before. Between 2-10 seconds :-(.

Are there any reasons?
Nov 20, 2013 at 8:44 PM
We are in the stage of rewriting this (very old) part of Catel. However, it's all a matter of resources. See https://catelproject.atlassian.net/browse/CTL-206 for more details.
Dec 2, 2013 at 9:59 AM
Thanks for you answer.

But I don't understand waht you mean with " However, it's all a matter of resources".
Also I have read the isue.

But I still don't understand why my Mainwindow is still dimmed after I have called wait.Hide().
What happens in catel after I called wait.Hide??
Dec 2, 2013 at 11:39 AM
With limited resources I mean: we all do this for free, we don't have all the time of the world to maintain all features of Catel with every request that comes in. We are in the stage of rewriting this part of Catel (PleaseWaitWindow), but since I will have to do that, it will probably be not before 2014.

To see what happens in the Hide method, see this.
Dec 2, 2013 at 12:16 PM
Ok. I solved my problem. With the call of DispatcherHelper.DoEvents();

But I have also an other problem with the pleasewaitwindow. Maybe you can help me witout spending a lots of time for this.
Little bit code. Its easier to explian than lots of words. :-)
var wait = ServiceLocator.ResolveType<IPleaseWaitService>();
ICollectionView collectionview = new CollectionView(GetItems());
collectionview .MoveCurrentTo(specialItem);
The call of MoveCurrentTo() lead to that the Plasewaitwindow is hidden before the wait.Hide is called.

Maybe you have an idea why this happens?
Dec 2, 2013 at 12:20 PM
Maybe you can call wait.Hide() in a BeginInvoke. Probably the MoveCurrentTo is put at the end of the invocation list by the CollectionView class.
Dec 2, 2013 at 12:42 PM
Ok. Why call wait.Hide() in a BeginInvoke? Im' confused sorry.
Dec 2, 2013 at 12:44 PM
Yes, just try it. It might be a Dispatcher thing where (MoveCurrentTo is called using BeginInvoke (internally)). That is the only explanation I have without checking it in the source.
Dec 2, 2013 at 1:10 PM
Ok. I add a little bit more code to demonstrate what I do?
public class viewModelA
   public void  Load()
      var wait = ServiceLocator.ResolveType<IPleaseWaitService>();

       var mediator = ServiceLocator.ResolveType<IMessageMediator>();
       mediator.SendMessage("LoadSometing", "Load");



public class viewModelB
    public viewModelB()
       var mediator = ServiceLocator.ResolveType<IMessageMediator>();
       mediator.Register(this, OnLoad, "Load");

   public void  OnLoad()
So I don't understand why it should help to call wait.Hide() in a Dispatcher. Because the Pleasewaitwindow is hidden before i call hide?
I don't get it.
Dec 3, 2013 at 7:58 PM
First of all, we really recommend that you inject your services into the ViewModel using the constructor. Let's assume that you did it via the service locator to make the example more clear.

I see you are using the right method of the mediator (SendMessage instead of SendMessageAsync). Can you please upload a repro so I can easily test this? I can't see from the code why this wouldn't work. I quickly checked the CollectionView source code, they don't use BeginInvoke, so that shouldn't be an issue.
Dec 4, 2013 at 7:27 AM
Ok I try to make a repro and add a new isue.

To your first sentence:
First of all, we really recommend that you inject your services into the ViewModel using the constructor.
So you mean, I have to create a member variable for every Service, and initialize it in constructor?
public class viewModelA
    private     IPleaseWaitService _wait;
     private   IMessageMediator _mediator;
   public viewModelA()
       _wait = ServiceLocator.ResolveType<IPleaseWaitService>();
       _mediator = ServiceLocator.ResolveType<IMessageMediator>();       

   public void  Load()
       _mediator.SendMessage("LoadSometing", "Load");
What if I need a new Instance of a special service every time I call a metod?

Let's assume that you did it via the service locator to make the example more clear.
This sentence I read multiple times, I don't realy understand. Sorry.
Dec 4, 2013 at 7:41 AM
1) . Yes, that is what we recommend. Then use this constructor:
public viewModelA(IPleaseWaitService pleaseWaitService, IMessageMediator messageMediator)
    _wait = pleaseWaitService;
    _mediator = messageMediator;
See the docs for more info.

2) Never mind, I said I was assuming that you only did that to make the example easier to understand. But it wasn't, so ignore that part.
Dec 4, 2013 at 8:26 AM

But what are about such things
public void Load()
   using (var machineDataManager = ServiceLocator.ResolveType<IMachineDataManager>())
            Machines = new ObservableCollection<Machine>(machineDataManager.GetMachines());
every time I call the Load method I need a new Instance of IMachineDataManager.

2.) Ah ok. Now I understand.
Dec 4, 2013 at 8:32 AM
You probably have good reasons to need a new instance every time you call the method (not per view model). Then you can do this:
var dependencyResolver = this.GetDependencyResolver();
using (var machineDataManager = dependencyResolver.Resolve<IMachineDataManager>())
The reason is that we will (or already do) support nested containers and this will ensure that you will get the right dependency resolver for the right contrainer in the right scope.