1
Vote

CloseAll() desktop manager bug

description

The problem is in VirtualDesktopManager CloseAll method. It is used when I want all windows to be closed, so I can simulate the restart of the application. The behaviour of this method is very weird sometimes.
 
If it is called normally with command in the viewmodel:
this.GetService<IVirtualDesktopManager>().CloseAll();
 
It completely hangs the application due to parallelization and it stays in loop in method (VirtualDesktopManager.cs):
private void DeactivateAll()
{
 this.Desktops.AsParallel().ForAll(vd => vd.Deactivate());
 //this.Desktops.ForEach(vd => vd.Deactivate()); // This is the solution to the hang of the application
}
 
The bottom line was added by me during testing and it fixes the spinlock. However the method has another problem. It disables any new windows opening, except modal windows, no windows, nothing.

comments

Legoless wrote Apr 27, 2011 at 1:19 AM

After looking more into the problem, I actually figured out what is wrong, well what happens. To use parallelization we should execute this method with a background task:

Task t = Task.Factory.StartNew
        (
            () =>
            {
                  this.GetService<IVirtualDesktopManager>().CloseAll();
            }
);

The method works when executed this way. But the other problem still persists, you can only use Modal navigate mode, if you dont, no window is displayed. Apparently CloseAll () method also closes the current desktop, meaning you cannot display windows. So before navigating again, you need to call it's ActivateDefaultDesktop() method.

As this is not really a bug, it just happened because of missing documentation on how to use a function. I leave this to you Carlos, to either fix the method in general or leave this issue logged for others to see how this can be solved.

Best Regards,

Legoless

carlosga wrote Apr 27, 2011 at 6:33 AM

Close All, is used on logout to close all windows and widgets, and deactivates all desktops, before showing the login window.

It maybe a good idea to have a method for closing only the windows in the active desktop, ¿may that help to achieve what you need ?

Legoless wrote Apr 27, 2011 at 1:56 PM

Yes, I figured that out later, hehe. If you want you can write that method, but I achieved this with activating the default desktop after closing all windows. ;)

carlosga wrote Apr 28, 2011 at 8:31 AM

Hello:

I will think on that, having a method for closing all windows in the current desktop only, maybe of help.