Exemplo n.º 1
0
        private void MS_SocketMonitor_Click(object sender, EventArgs e)
        {
            SocketMonitor nwin = new SocketMonitor();

            nwin.Dock = DockStyle.Fill;
            CreateNewTest(nwin, "Socket通信监视器[" + DateTime.Now.ToString("HHmmss") + "]", Properties.Resources.monitor_socket_icon);
        }
Exemplo n.º 2
0
 private void btnExec_Click(object sender, EventArgs e)
 {
     if (btnExec.Text.Equals("Start"))
     {
         _Exit        = false;
         btnExec.Text = "Stop";
         cbFillter.Items.Clear();
         cbFillter.Items.Add("<None>");
         cbFillter.SelectedIndex = 0;
         cbProtocol.Items.Clear();
         cbProtocol.Items.Add("<None>");
         cbProtocol.SelectedIndex = 0;
         lvSkt.View = View.Details;
         lvSkt.Items.Clear();
         sw.Restart();
         _Svr = new SocketMonitor(cbIP.Text);
         //_Svr.Start();
         _Monitor = Task.Factory.StartNew(MonitorTask);
     }
     else
     {
         _Exit = true;
         _Monitor.Wait(2000);
         try { _Monitor.Dispose(); }
         catch { }
         _Monitor = null;
         //_Svr.Shutdown();
         sw.Stop();
         btnExec.Text = "Start";
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="client"></param>
        /// <param name="monitor"></param>
        internal void Initialize(Socket client, SocketMonitor monitor)
        {
            Preconditions.ThrowIfNull(client, "client");
            Preconditions.ThrowIfNull(monitor, "monitor");

            this.Monitor      = monitor;
            this.connector    = client;
            this.ConnectionID = monitor.GetNextConnectionID();

            //set send SAE
            if (!this.Monitor.SocketEventArgsPool.TryGet(out this.sendSAE))
            {
                throw new Exception("无法获取接收SocketAsyncEventArgs对象");
            }
            this.sendSAE.Completed += new EventHandler <SocketAsyncEventArgs>(this.SAE_SendCompleted);

            //set receive SAE
            if (!this.Monitor.SocketEventArgsPool.TryGet(out this.receiveSAE))
            {
                throw new Exception("无法获取接收SocketAsyncEventArgs对象");
            }
            ArraySegment <byte> receiveBuffer;

            if (!this.Monitor.ReceiveBufferPool.TryGet(out receiveBuffer))
            {
                throw new Exception("无法获取发送Buffer");
            }
            this.receiveSAE.SetBuffer(receiveBuffer.Array, receiveBuffer.Offset, receiveBuffer.Count);
            this.receiveSAE.Completed += new EventHandler <SocketAsyncEventArgs>(this.SAE_ReceiveCompleted);

            this.packet = this.Monitor.Protocol.CreatePacket(this.Monitor.PacketBufferPool);
        }
Exemplo n.º 4
0
        private void materialFlatButton2_Click(object sender, EventArgs e)
        {
            SocketMonitor nwin = new SocketMonitor();

            nwin.Dock = DockStyle.Fill;
            if (LanguageSet.Language == "0")
            {
                CreateNewTest(nwin, "Socket 通信监视器[" + DateTime.Now.ToString("HHmmss") + "]", Properties.Resources.monitor_socket_icon);
            }
            else
            {
                CreateNewTest(nwin, "Socket Communication monitor[" + DateTime.Now.ToString("HHmmss") + "]", Properties.Resources.monitor_socket_icon);
            }
        }
        private StartupWorkflow(
            bool triggerSocketMonitor,
            bool triggerOrderMonitor,
            bool triggerAccountMonitor,
            bool triggerCandleMonitor,
            bool triggerStrategyMonitor,
            bool triggerOverlayMonitor) : this()
        {
            // See this link for very detailed explanation of how TaskCompletionSource can block
            // https://blogs.msdn.microsoft.com/seteplia/2018/10/01/the-danger-of-taskcompletionsourcet-class/

            if (triggerSocketMonitor)
            {
                SocketMonitor.SetResult(true);
            }
            if (triggerOrderMonitor)
            {
                OrderMonitor.SetResult(true);
            }
            if (triggerAccountMonitor)
            {
                AccountMonitor.SetResult(true);
            }
            if (triggerCandleMonitor)
            {
                CandleMonitor.SetResult(true);
            }
            if (triggerStrategyMonitor)
            {
                StrategyMonitor.SetResult(true);
            }
            if (triggerOverlayMonitor)
            {
                OverlayMonitor.SetResult(true);
            }
        }