Exemplo n.º 1
0
        static void Main(string[] args)
        {
            System.Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelKeyPressEventHandler);
            System.Console.BufferWidth     = 1000;

            stopWaitEvent = new ManualResetEvent(false);

            CommandLineParser parser = new CommandLineParser(args);

            string instanceName = parser["instance"];

            if (String.IsNullOrEmpty(instanceName))
            {
                instanceName = ConfigurationManager.AppSettings["instance"];
            }

            instance = InstanceFactory.CreateInstance <InstanceBase>("Imi.Wms.Mobile.Server", "Imi.Wms.Mobile.Server.ServerInstance", instanceName);

            try
            {
                instance.Initialize();
                instance.Start();

                System.Console.WriteLine("Press Ctrl+C to terminate...");

                stopWaitEvent.WaitOne();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
            }
            finally
            {
                instance.Stop();
            }

            System.Console.WriteLine("Press any key to exit...");
            System.Console.ReadKey();

            Environment.Exit(0);
        }
Exemplo n.º 2
0
        protected override void OnStop()
        {
            if (instance != null)
            {
                try
                {
                    instance.Stop();
                }
                finally
                {
                    try
                    {
                        AppDomain.Unload(instance.AppDomain);
                    }
                    catch
                    {
                    }
                }
            }

            base.OnStop();
        }