Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Welcome, Guest. Please login or register.
November 24, 2017, 02:29:53 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]
Author Topic: Startup idiom  (Read 6730 times)
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:

    class ApplicationRunner
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        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
Global Moderator
Hero Member
Posts: 2871

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


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.

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:

protected override void OnStartup(StartupEventArgs e)
MainWindow window = new MainWindow();
ApplicationFacade facade = (ApplicationFacade) ApplicationFacade.Instance;
Pages: [1]
Jump to: