コード例 #1
0
ファイル: Form1.cs プロジェクト: radtek/Freya
        private void ExitFreya()
        {
            if (radioServer != null)
            {
                radioServer.Stop();
            }
            if (radioServer1 != null)
            {
                radioServer1.Stop();
            }

            if (m_DMSCancellationSource != null)
            {
                m_DMSCancellationSource.Cancel();
                m_DMSCancellationSource = null;
            }

            if (this != null)
            {
                this.InvokeIfRequired(() =>
                {
                    this.WindowState         = FormWindowState.Minimized;
                    this.notifyIcon1.Visible = false;
                    this.notifyIcon1.Dispose();
                    Close();
                });
            }

            //Environment.Exit(Environment.ExitCode);
            Application.Exit();
        }
コード例 #2
0
ファイル: ProxyService.cs プロジェクト: radtek/Freya
        /// <summary>
        /// Handle the service stop event by stopping all proxies.
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                StopProxies();

                for (int n = 0; n < Workers.Length; n++)
                {
                    if (Workers[n] != null)
                    {
                        try
                        {
                            Workers[n].Enable = false;
                            Workers[n].Stop();
                            Workers[n] = null;
                        }
                        catch (Exception) { }
                    }
                }

                if (radioServer != null)
                {
                    radioServer.Stop();
                }

                logger.WriteLine("[Service] OnStop() finished. Service Stopped.");
            }
            catch (Exception ex) { logger.WriteLine("[Service] OnStop() - Stop Service Excpetion:" + ex.Message); }
        }
コード例 #3
0
        public override void WillTerminate(NSNotification notification)
        {
            _ipcServer?.Stop();
            _ipcServer?.Dispose();

            // Insert code here to tear down your application
            NSEvent.RemoveMonitor(_eventMonitor);
        }
コード例 #4
0
 public static void Stop()
 {
     if (server != null)
     {
         server.Stop();
         server = null;
     }
 }
コード例 #5
0
        static void Main()
        {
            Console.SetWindowSize(60, 10);
            //Settings for single instance app start
            const string appName = "admy_server";
            bool         createdNew;

            mutex = new Mutex(true, appName, out createdNew);
            if (!createdNew)
            {
                //app is already running! Exiting the application
                return;
            }
            //Settings for single instance app end

            var s = new IpcServer();

            s.Start(12345); // Passing no port selects a free port automatically.

            Console.WriteLine("Started server on port {0}, input \"quit\" to exit", s.Port);

            s.ReceivedRequest += (sender, args) =>
            {
                args.Response = args.Request;
                Console.WriteLine("I've got: " + args.Response);
                try
                {
                    Process.Start(args.Response);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                args.Handled = true;
            };

            bool   stay = true;
            string command;

            while (stay)
            {
                command = Console.ReadLine();
                if (command == "quit")
                {
                    stay = false;
                }
            }
            s.Stop();
        }
コード例 #6
0
        protected override void OnExit(ExitEventArgs e)
        {
            _ipcServer?.Stop();
            _ipcServer?.Dispose();

            _hotkey.Unregister();

            _explorerUpdateTimer.Change(Timeout.Infinite, Timeout.Infinite);

            var explorerHandler = TinyIoCContainer.Current.Resolve <WindowsExplorerHandler>();

            explorerHandler.CleanTitles();

            _notifyIcon.Dispose();

            base.OnExit(e);
        }
コード例 #7
0
        private static void Main()
        {
            var s = new IpcServer();

            s.Start(12345);

            Console.WriteLine("Started server.");

            s.ReceivedRequest += (sender, args) =>
            {
                Console.WriteLine("Received: " + args.Request);
                args.Response = "Super: " + args.Request;
                args.Handled  = true;
            };

            while (true)
            {
                Thread.Sleep(1000);
            }

            s.Stop();
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            var server = new IpcServer("ExamplePipeName");

            server.Connected    += id => Console.WriteLine($"Connected {id}");
            server.Disconnected += id => Console.WriteLine($"Disconnected ({id})");
            server.Message      += (id, message) => Console.WriteLine($"Message Received ({id}): {message}");

            server.Connect();

            Thread.Sleep(5000);

            Console.WriteLine("Sending tests to clients");

            Thread.Sleep(1000);

            server.Send("Server 1");

            Thread.Sleep(1000);

            server.Send("Server 2");

            Thread.Sleep(1000);

            server.Send("Server 3");

            Thread.Sleep(1000);

            server.Send("Server 4");

            Thread.Sleep(1000);

            server.Stop();

            Console.WriteLine("End");
        }
コード例 #9
0
 private void button3_Click(object sender, EventArgs e)
 {
     s.Stop();
 }
コード例 #10
0
 private void StopServerBtn_OnClick(object sender, RoutedEventArgs e)
 {
     _server.Stop();
 }
コード例 #11
0
 void StopServer(IpcServer s)
 {
     s.Stop();
 }