コード例 #1
0
    /// <inheritdoc />
    public override void StopHostingService()
    {
        if (!IsHostingServiceRunning)
        {
            return;
        }
        Log("Stopping");
        MyHttpListener.Stop();
        socketListener.Stop();

        socketListener = null;
    }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (ss.IsListening)
            {
                try
                {
                    ss.Stop();

                    this.Invoke((MethodInvoker) delegate
                    {
                        //ss.Connected -= new EventHandler<AsyncSocketUserToken>(ss_Connected);
                        //ss.DataReceived -= new EventHandler<AsyncSocketUserToken>(ss_DataReceived);
                        //ss.DataSent -= new EventHandler<AsyncSocketUserToken>(ss_DataSent);
                        //ss.Disconnected -= new EventHandler<AsyncSocketUserToken>(ss_Disconnected);
                        //ss.ErrorOccurred -= new EventHandler<AsyncSocketErrorEventArgs>(ss_ErrorOccurred);

                        richTextBox1.AppendText("-> Server stop!");
                        richTextBox1.AppendText(Environment.NewLine);
                        richTextBox1.ScrollToCaret();
                    });
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }
            else
            {
                this.Invoke((MethodInvoker) delegate
                {
                    richTextBox1.AppendText("-> Server is stoped!");
                    richTextBox1.AppendText(Environment.NewLine);
                    richTextBox1.ScrollToCaret();
                });
            }
        }