예제 #1
0
		static int Main()
		{
			//the host environment itself can be made into a class!
			WpfHostEnvironment host = new WpfHostEnvironment();
			host.UnhandledException += (sender, e) =>
			{
				System.Windows.MessageBox.Show(e.ExceptionObject.ToString());
				if(e.IsTerminating)
					host.ShutDown();
			};

			//but it's hard; for example, if you move this constructor before the host constructor
			//the WinForms Application calls will give you grief, because a form will have been constructed already
			//this demonstrates, yet again, why global state is a bad thing
			IAsynchronousHostableProgram program = new FinalMixedDesignProgram();

			return host.Run(program);
		}
예제 #2
0
        static int Main()
        {
            //the host environment itself can be made into a class!
            WpfHostEnvironment host = new WpfHostEnvironment();

            host.UnhandledException += (sender, e) =>
            {
                System.Windows.MessageBox.Show(e.ExceptionObject.ToString());
                if (e.IsTerminating)
                {
                    host.ShutDown();
                }
            };

            //but it's hard; for example, if you move this constructor before the host constructor
            //the WinForms Application calls will give you grief, because a form will have been constructed already
            //this demonstrates, yet again, why global state is a bad thing
            IAsynchronousHostableProgram program = new FinalMixedDesignProgram();

            return(host.Run(program));
        }