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); }
protected override void OnStart(string[] args) { if (string.IsNullOrEmpty(assemblyName)) { throw new ArgumentException("Instance assembly not specified."); } if (string.IsNullOrEmpty(instanceTypeName)) { throw new ArgumentException("Instance type name not specified."); } if (string.IsNullOrEmpty(instanceName)) { throw new ArgumentException("Instance name not specified."); } instance.Initialize(); instance.Start(); base.OnStart(args); }
protected override void OnStart(string[] args) { instance = InstanceFactory.CreateInstance("", ""); instance.Initialize(); instance.Start(); }