コード例 #1
0
ファイル: Program.cs プロジェクト: bp2008/NetworkSpeedTest
        private static void btnStartTemporary_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn.Text.StartsWith("Start"))
            {
                ServiceWrapper.Start();
                btn.Text = "Stop Temporary Instance";
            }
            else
            {
                ServiceWrapper.Stop();
                btn.Text = "Start Temporary Instance";
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: bp2008/NetworkSpeedTest
        static void Main(string[] args)
        {
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            config.Load();
            config.SaveIfNoExist();

            if (Environment.UserInteractive)
            {
                string Title       = "Network Speed Test " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " Service Manager";
                string ServiceName = "NetworkSpeedTest";

                ButtonDefinition btnStartTemporary = new ButtonDefinition("Start Temporary Instance", btnStartTemporary_Click);
                ButtonDefinition btnPort           = new ButtonDefinition("Web Port: " + config.port, btnPort_Click);

#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    btnStartTemporary.Text = "Stop Temporary Instance";
                    ServiceWrapper.Start();
                }
#endif

                ButtonDefinition[] customButtons = new ButtonDefinition[] { btnStartTemporary, btnPort };



                System.Windows.Forms.Application.Run(new ServiceManager(Title, ServiceName, customButtons, new DuplexTestButton()));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new MainSvc()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }