// 将消息发送给下游模块 void SendMessage(List <MessageRecord> records) { SendMessageEventHandler handler = this.SendMessageEvent; // 下级的代码不影响 foreach (MessageRecord record in records) { if (this._sendedTable.ContainsKey(record.id)) { continue; } dp2WeiXinService.Instance.WriteDebug2("开始处理:" + record.id); // 内容太多了,不适合加 //dp2WeiXinService.Instance.WriteDebug2("消息内容:" + record.data); // 发送 if (handler != null) { SendMessageEventArgs e = new SendMessageEventArgs(); e.Message = record; handler(this, e); } dp2WeiXinService.Instance.WriteDebug2("处理结束:" + record.id); if (this._sendedTable.Count < C_SendTable_MaxCount) //大于了5K则不再给里面增加了。 { this._sendedTable[record.id] = DateTime.Now; } } }
// 将消息发送给下游模块 void SendMessage(List <MessageRecord> records) { SendMessageEventHandler handler = this.SendMessageEvent; // 下级的代码不影响 foreach (MessageRecord record in records) { if (this._sendedTable.ContainsKey(record.id)) { continue; } this.WriteLog("开始处理:" + record.id, dp2WeiXinService.C_LogLevel_3); // 发送 if (handler != null) { SendMessageEventArgs e = new SendMessageEventArgs(); e.Message = record; handler(this, e); } this.WriteLog("处理结束:" + record.id, dp2WeiXinService.C_LogLevel_3); if (this._sendedTable.Count < C_SendTable_MaxCount) //大于了5K则不再给里面增加了。 { this._sendedTable[record.id] = DateTime.Now; } } }
// 将消息发送给下游模块 void SendMessage(List <MessageRecord> records) { SendMessageEventHandler handler = this.SendMessageEvent; foreach (MessageRecord record in records) { if (this._sendedTable.ContainsKey(record.id)) { continue; } this.WriteLog("开始处理:" + record.id); // 发送 if (handler != null) { SendMessageEventArgs e = new SendMessageEventArgs(); e.Message = record; handler(this, e); } this.WriteLog("处理结束:" + record.id); this._sendedTable[record.id] = DateTime.Now; } }
/// <summary> /// Sends the message. /// </summary> /// <param name="message">The message.</param> protected void SendMessage(string message) { SendMessageEventHandler handler = OnSendMessage; if (handler != null) { handler(message); } }
private static void TcpClientAsyncCallBackEventHandler(IAsyncResult ar) { Console.WriteLine("进入回调......"); TcpClient tcpClient = (TcpClient)ar.AsyncState; tcpClient.EndConnect(ar); _bw = new BinaryWriter(tcpClient.GetStream()); var msg = "你好服务器,我是客户端"; //同步发送消息 //_bw.Write("你好服务器,我是客户端"); //_bw.Flush(); SendMessageEventHandler sm = SendMessage; sm.BeginInvoke(msg, SendMessageAsyncCallBack, sm); Console.WriteLine("消息发送完毕"); }
public void RegisterSendMessageEvent(SendMessageEventHandler onSendEvent) { _sendMessageEvent += onSendEvent; }