Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
November 24, 2017, 02:30:17 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Startup idiom  (Read 6731 times)
JCabot
Courseware Beta
Jr. Member
***
Posts: 11


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

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:

Code:
    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 AM by JCabot » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



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

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 AM »

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:

Code:
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
Jump to: