Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Startup idiom  (Read 11256 times)
JCabot
Courseware Beta
Jr. Member
***
Posts: 11


View Profile Email
« on: January 16, 2008, 09:53:20 »

What's the recommended way of performing startup in a windows application? The way I have been playing around with it, I have the following classes:

:
    class ApplicationRunner
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        static void Main()
        {
            IFacade facade = ApplicationFacade.getInstance();
            facade.startup(new Form1());
        }
    }

    class ApplicationFacade : Facade, IFacade
    {
        ...
        public override void startup(object app)
        {
            notifyObservers(ApplicationFacade.APP_STARTUP, app);
            Application.Run(app as Form);
        }
    }

just wondered what other peoples opinions are? Is there really a need to have an ApplicationRunner class? or just put the main method in the ApplicationFacade? Where do you recommend putting Application.Run (the built in .NET thing) in the facade or startup command? What are the Java guys doing?

[Edit: oops forgot some parts]
« Last Edit: January 16, 2008, 09:57:22 by JCabot » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: January 16, 2008, 08:23:28 »

Jason,

You might want to post this question to the Port Authority (with less C# and more generically stated) so the Java guys will see it.

-=Cliff>
Logged
adamczak
Moderator
Jr. Member
*****
Posts: 10


View Profile Email
« Reply #2 on: February 03, 2009, 01:06:17 »

I wanted to post a startup idiom for WPF applications.  There is a timing issue on when the main window is available for the application facade startup.  The way I found that works great is to override your OnStartup event of you application in your App.xaml.cs file (this is the default file name generated by Visual Studio), and instantiate your main window by hand.  This is the suggested method of doing things if you need access to your main window in the startup event.  So first, you have to remove the StartupUri attribute from your App.xaml source.  Then you override your OnStartup event so it looks something like this:

:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MainWindow window = new MainWindow();
ApplicationFacade facade = (ApplicationFacade) ApplicationFacade.Instance;
facade.Startup(window);
window.Show();
}
Logged
Pages: [1]
Print