Пример #1
0
        private void btnAsync_Click(object sender, EventArgs e)
        {
            var count = int.Parse(txtCount.Text);

            Csl.Wl("----------------------------------------------");
            Parallel.For(0, count, (x) =>
            {
                try
                {
                    using (var sclient = new OctMQClient())
                    {
                        sclient.Init(txtip.Text, int.Parse(txtport.Text), ClientType.Request);
                        var msg = sclient.CreateMessage();
                        msg.Append(int.Parse(txtSeat.Text));
                        msg.Append(txtName.Text, Encoding.UTF8);
                        sclient.Send(msg);
                        var rmsg   = sclient.ReceiveMessage();
                        var ret    = rmsg.Pop().ConvertToInt32();
                        var reqStr = rmsg.Pop().ConvertToString(Encoding.UTF8);
                        Csl.Wl(string.Format("判断值:{0},结果:{1},第几个进程:{2}", ret, reqStr, x));
                    }
                }
                catch (Exception)
                {
                }
            });
            Csl.Wl("----------------------------------------------");
        }
Пример #2
0
 /// <summary>
 /// 发送响应消息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSend_Click(object sender, EventArgs e)
 {
     using (_client = new OctMQClient())
     {
         _client.Init(txtip.Text, int.Parse(txtport.Text), ClientType.Request);
         var content = txtContent.Text;
         var msg     = _client.CreateMessage();
         msg.Append(content, Encoding.UTF8);
         _client.Send(msg);
         var rmsg   = _client.ReceiveMessage();
         var reqStr = rmsg.Pop().ConvertToString(Encoding.UTF8);
         Csl.Wl(reqStr);
     }
 }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (_client = new OctMQClient())
     {
         _client.Init(txtip.Text, int.Parse(txtport.Text), ClientType.Request);
         var msg = _client.CreateMessage();
         msg.Append(int.Parse(txtSeat.Text));
         msg.Append(txtName.Text, Encoding.UTF8);
         _client.Send(msg);
         var rmsg   = _client.ReceiveMessage();
         var ret    = rmsg.Pop().ConvertToInt32();
         var reqStr = rmsg.Pop().ConvertToString(Encoding.UTF8);
         Csl.Wl(string.Format("判断值:{0},结果:{1}", ret, reqStr));
     }
 }