/// <summary> /// 主线程事件驱动Timer相应 /// </summary> private void eventTickTimer_Tick(object sender, System.EventArgs e) { NetEvent evt = null; while (!NetEventQueue.IsEmpty && NetEventQueue.TryDequeue(out evt)) { switch (evt.evt) { case ENetEvent.Connected: this.pictureBoxLog.Visible = false; this.labelTips.Visible = false; this.splitContainer.Visible = true; this.lbStatus.Text = "Connected"; break; case ENetEvent.Disconnected: this.lbStatus.Text = "Disonnected"; break; case ENetEvent.Start: this.lbStatus.Text = "App Start"; this.pictureBoxLog.Visible = false; this.labelTips.Visible = false; this.splitContainer.Visible = true; break; case ENetEvent.Log: this.lbStatus.Text = "Log"; if (evt.log != null) { ShowLog(evt.log); m_logList.Add(evt.log); } else { ListViewItem view = this.listViewLog.Items.Add("", 0); view.SubItems.Add(evt.data); } this.pictureBoxLog.Visible = false; this.labelTips.Visible = false; this.splitContainer.Visible = true; break; default: this.lbStatus.Text = "Unknown Net Event"; break; } // end of switch } // end of while }
public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { NetEvent evt = new NetEvent(ENetEvent.Log, requestInfo.Body); evt.data = requestInfo.Body; try { LogItem log = Newtonsoft.Json.JsonConvert.DeserializeObject <LogItem>(requestInfo.Body); if (log != null) { log.ConvertBase64(); } evt.log = log; } catch (System.Exception ex) { } MainForm.NetEventQueue.Enqueue(evt); }