private void asynReceive() //异步接受 {
MessageQueue myQueue = new MessageQueue(".\\Private$\\MSMQDemo");
myQueue.Formatter = new XmlMessageFormatter(new Type[]
{typeof(String)}); myQueue.ReceiveCompleted +=
new ReceiveCompletedEventHandler(MyReceiveCompleted);
myQueue.BeginReceive(); return;
} private static void MyReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult) { MessageQueue mq = (MessageQueue)source; System.Messaging.Message m = mq.EndReceive(asyncResult.AsyncResult); Console.WriteLine("Message: " + (string)m.Body); mq.BeginReceive();
return; }```上面是MSMQ的异步接收`。返回值都是void。 请问我怎么才能接收到数据,比如我要将收到的数据放到TextBox里``该怎么做????
MessageQueue myQueue = new MessageQueue(".\\Private$\\MSMQDemo");
myQueue.Formatter = new XmlMessageFormatter(new Type[]
{typeof(String)}); myQueue.ReceiveCompleted +=
new ReceiveCompletedEventHandler(MyReceiveCompleted);
myQueue.BeginReceive(); return;
} private static void MyReceiveCompleted(Object source, ReceiveCompletedEventArgs asyncResult) { MessageQueue mq = (MessageQueue)source; System.Messaging.Message m = mq.EndReceive(asyncResult.AsyncResult); Console.WriteLine("Message: " + (string)m.Body); mq.BeginReceive();
return; }```上面是MSMQ的异步接收`。返回值都是void。 请问我怎么才能接收到数据,比如我要将收到的数据放到TextBox里``该怎么做????
你的和我的不太一样
你的应该这样解决
if(数据流中找到你定义的结束标志了)
{
textbox.text=你的数据去掉结束标志;
}我的问题是在Socket编程中如果这么写入,有可能数据被其他用户覆盖调