Inheritance: System.MarshalByRefObject, IDisposable
Beispiel #1
0
        static void Main(string[] args)
        {
            TaskBroker.Logger.CommonTape tape = new TaskBroker.Logger.CommonTape(new TaskBroker.Logger.LoggerEndpoint[]{
                    new TaskBroker.Logger.ConsoleEndpoint(),
                    new TaskBroker.Logger.FileEndpoint("log.txt")
                });

            TaskUniversum.ModApi.ScopeLogger.RegisterCommonTape(tape);
            bool benchConfiguration = false;// Array.IndexOf(args, "benchTasks") >= 0;// for plan or other params depends on tasks calculation

            if (Array.IndexOf(args, "inline") >= 0 || System.Diagnostics.Debugger.IsAttached)
            {
                ManualResetEvent mre = new ManualResetEvent(false);
                BrokerApplication ba = new BrokerApplication();
                ba.Run(mre, benchConfiguration, false);
                mre.WaitOne();
            }
            else
            {
                ApplicationKeeper.AppdomainLoop(benchConfiguration);
            }
            Console.WriteLine("! Application MAIN EXIT.");
            Console.ReadLine();
            return;
        }
Beispiel #2
0
        public static void AppdomainLoop()
        {
            sync = new ManualResetEvent(false);
            while (true)
            {
                sync.Reset();
                // create appdomain
                logger.Debug("domain starting.");

                AppDomainSetup setup  = AppDomain.CurrentDomain.SetupInformation;
                AppDomain      Domain = AppDomain.CreateDomain("ApplicationKeeper", null, setup);
                //
                BrokerApplication app = (BrokerApplication)Domain.CreateInstanceAndUnwrap(
                    typeof(BrokerApplication).Assembly.FullName,
                    typeof(BrokerApplication).FullName);
                //RunAppInSeparateThread(app);
                app.Run(sync, true);
                // waitfor sync
                sync.WaitOne();

                // unload appdomain
                AppDomain.Unload(Domain);

                logger.Debug("domain unloaded.");

                GC.Collect();                  // collects all unused memory
                GC.WaitForPendingFinalizers(); // wait until GC has finished its work
                GC.Collect();
            }
        }
Beispiel #3
0
        static void AppThread(object o)
        {
            BrokerApplication app = (BrokerApplication)o;

            app.Run(sync);
        }
Beispiel #4
0
        static void RunAppInSeparateThread(BrokerApplication app)
        {
            Thread thread = new Thread(new ParameterizedThreadStart(AppThread));

            thread.Start(app);
        }