Best practice to launch login modal before the shell

Topics: Prism v2 - WPF 3.5
Aug 15, 2009 at 10:09 AM

Hi i would like more explanations about when and where i'll launch my login window.

When i do something like that (See code below) the shell doesn't display.

     protected override DependencyObject CreateShell()
        {
            
            Connection.Connection con = new V2000Shell.Connection.Connection(proxy, app_Langue);
            con.ShowDialog();
            _currentUser = con.getCurrentUser();
            if (_currentUser == null)
            {
                Environment.Exit(-1);
                return null;
            }
            else
            {
                Shell shell = new Shell();
                shell.Show();
                return shell;
            }
        }

But when i create the shell first like that (See code below) it is displays.

    protected override DependencyObject CreateShell()
        {
            Shell shell = new Shell();
            Connection.Connection con = new V2000Shell.Connection.Connection(proxy, app_Langue);
            con.ShowDialog();
            _currentUser = con.getCurrentUser();
            if (_currentUser == null)
            {
                Environment.Exit(-1);
                return null;
            }
            else
            {
                shell.Show();
                return shell;
            }
        }

 

In the two scenari, _currentUser is not null.

Thanks

Aug 18, 2009 at 10:04 AM
Edited Aug 18, 2009 at 10:26 AM

Sorry - just realised my reply wasn't valid!!

Aug 18, 2009 at 6:56 PM

Hi Blochaou,

I have tried to reproduce your scenario,  assigning different values to _currentUser with no success.  With both approaches, if the _currentUser was not null, the Shell would show. If the second approach does work for you can use it. You could also try the following approach (if it works) to avoid instantiating the Shell unless it is necessary:

    protected override DependencyObject CreateShell()

        {

            Shell shell;

            Connection.Connection con = new V2000Shell.Connection.Connection(proxy, app_Langue);

            con.ShowDialog();

            _currentUser = con.getCurrentUser();

            if (_currentUser == null)

            {

                Environment.Exit(-1);

                return null;

            }

            else

            {

                shell = new Shell();

                shell.Show();

                return shell;

            }

        }

The following thread provides some more information about showing login dialogs before loading the application:

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman