当前位置: 首页>>代码示例>>C#>>正文


C# Application.Start方法代码示例

本文整理汇总了C#中Application.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Application.Start方法的具体用法?C# Application.Start怎么用?C# Application.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application.Start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

		public static void Run(string[] args)
		{
			if (args.Length == 0)
			{
				Command.Application application = new Command.Application();
				IDisposable telnet = Parser.Listen(application, "telnet://:23");
				IDisposable tcp = Parser.Listen(application, "tcp://:20");
				IDisposable console = Parser.Listen(application, "console:///");
			}
			else
			{
				Application application = new Application();
				Settings.Module settings = new Settings.Module()
				{
					//Header = "<link href=\"resources/settings.css\" rel=\"stylesheet\" type=\"text/css\"/>\n <link href=\"resources/settings.css\" rel=\"stylesheet\" type=\"text/css\"/>",
				};
				settings.Load("loader", new Loader(settings));
				settings.Load("old.object", new Object());
				settings.Load("application", new Command.Application());
				application.Load(settings);
				application.Start();
				System.Threading.AutoResetEvent wait = new System.Threading.AutoResetEvent(false);
				application.OnClosed += () => wait.Set();
				wait.WaitOne();
				//application.Execute();
			}
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:27,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            if (args == null || args.Length < 1)
            {
                Usage();
                System.Environment.Exit(1);
            }

            int port = 0;
            var success = Int32.TryParse(args[0], out port);
            if (!success)
            {
                Usage();
                System.Environment.Exit(1);
            }

            bool simulationsSpecified = false;
            string simulationsPath = null;
            Moksy.Common.SimulationCollection simulations = new Common.SimulationCollection();
            simulationsPath = args.FirstOrDefault(f => f.StartsWith("/File:", StringComparison.InvariantCultureIgnoreCase));
            if (simulationsPath != null)
            {
                simulationsPath = simulationsPath.Substring(6);
                simulationsSpecified = true;
            }
            var log = args.FirstOrDefault(f => f.StartsWith("/Log:true", StringComparison.InvariantCultureIgnoreCase) || string.Compare(f, "/log", true) == 0);

            System.Reflection.Assembly thisExe;
            thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            var list = thisExe.GetManifestResourceNames();

            var header = ReadResource("Moksy.Host.Resources.Header.txt");
            var simulationsText = ReadResource("Moksy.Host.Resources.Simulations.txt");

            ApplicationDirectives parameters = new ApplicationDirectives() { Log = (log != null) };

            try
            {
                Console.WriteLine("----------------------------------------------");
                Console.WriteLine("MOKSY: REST API / JSON Endpoint Faking Toolkit");
                Console.WriteLine("----------------------------------------------");
                Console.WriteLine("by Grey Ham");
                Console.WriteLine();
                Console.WriteLine("See www.brekit.com for more information. ");
                Console.WriteLine("Source at https://github.com/greyham/Moksy");
                Console.WriteLine();

                if (simulationsSpecified)
                {
                    Console.Write(string.Format("Loading simulations from {0}...", simulationsPath));

                    var contents = System.IO.File.ReadAllText(simulationsPath);
                    simulations = Newtonsoft.Json.JsonConvert.DeserializeObject<Moksy.Common.SimulationCollection>(contents);

                    Console.WriteLine(string.Format("{0} simulations have been loaded. ", simulations.Count));
                    Console.WriteLine("");

                    // ASSERTION: We have loaded the simulations into memory.
                }

                Application app = new Application(port, parameters);
                app.Start();

                Console.WriteLine(string.Format("Running Moksy on Port {0}. ", port));
                Console.WriteLine(string.Format("Navigate to: http://localhost:{0} for a sanity test.", port));

                if (simulationsSpecified)
                {
                    Task.Factory.StartNew(() =>
                    {
                        Proxy proxy = new Proxy(port);
                        proxy.Wait(20);

                        // We need to wait until the service has started.
                        foreach (var simulation in simulations)
                        {
                            proxy.Add(simulation);
                        }
                    }, TaskCreationOptions.LongRunning
                    );
                }

                Console.WriteLine("Press a key to exit...");
                Console.ReadKey();
                app.Stop();
            }
            catch (System.AggregateException aggregate)
            {
                Console.WriteLine("ERROR: Launching Moksy.Host.Exe");
                Console.WriteLine(aggregate.Message);
                if (aggregate.InnerException.GetType().FullName == "System.ServiceModel.AddressAccessDeniedException")
                {
                    Console.WriteLine();
                    Console.WriteLine("Moksy launches a real HTTP Server and opens up a HTTP Endpoint so that your");
                    Console.WriteLine("tests and other services can hit it. ");
                    Console.WriteLine();
                    Console.WriteLine("By default, only applications launched as Administrator are allowed to");
                    Console.WriteLine("launch the HTTP Server and create the end-point. ");
                    Console.WriteLine();
                    Console.WriteLine("You are not running as Administrator. ");
//.........这里部分代码省略.........
开发者ID:aidancasey,项目名称:Moksy,代码行数:101,代码来源:Program.cs

示例3: RunApplication

        private static void RunApplication(string projectName, string path)
        {
            IRepository repository = new MemoryRepository();
            _application = new Application(repository, new WatcherFactory());
            Project project = _application.CreateProject(projectName, path);
            Console.WriteLine("Created project: " + project.Id);

            Console.WriteLine("Watching project folder...");
            _application.Start(project.Name);
        }
开发者ID:BookSwapSteve,项目名称:ContinuousSourceControl,代码行数:10,代码来源:Program.cs

示例4: StopStopsProjects

        public void StopStopsProjects()
        {
            var started = false;
            var stopped = false;
            var project = new ProjectStub
                              {
                                  Name = "Test",
                                  OnStart = () => started = true,
                                  OnStop = () => stopped = true,
                                  OnLoadState = () => { }
                              };
            var server = new Server(project);
            var application = new Application
                                  {
                                      Configuration = server
                                  };
            application.Start();

            // Give the projects time to start
            SpinWait.SpinUntil(() => started, TimeSpan.FromSeconds(5));
            Assert.IsTrue(started); 
            application.Stop();

            // Give the projects time to stop
            SpinWait.SpinUntil(() => stopped, TimeSpan.FromSeconds(5));
            Assert.IsTrue(stopped);
        }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:27,代码来源:ApplicationTests.cs

示例5: StartOpensCommunications

 public void StartOpensCommunications()
 {
     var initialised = false;
     var channel = new ChannelStub
                       {
                           OnInitialiseAction = () => initialised = true
                       };
     var server = new Server("Test", new[] { channel });
     var application = new Application
                           {
                               Configuration = server
                           };
     application.Start();
     Assert.IsTrue(initialised);
 }
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:15,代码来源:ApplicationTests.cs

示例6: Start

 public void Start(Application application)
 {
     application.Start();
     UpdateApplication(application);
     if (!IsStarted(application.Name))
     {
         throw new VcapException("Failed to start application.");
     }
 }
开发者ID:niemyjski,项目名称:ironfoundry,代码行数:9,代码来源:AppsHelper.cs


注:本文中的Application.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。