Esempio n. 1
0
 private void m_buttonParallelTest4Client_Click(object sender, EventArgs e)
 {
     Task.Run(() =>
     {
         var strIPRemote = this.m_textBoxIPRemote4Send.Text;
         var iPortRemote = Convert.ToInt32(this.m_textBoxPortRemote4Send.Text);
         var strMsg      = this.m_textBoxSendAsync4Client.Text;
         byte[] arrMsg   = ByteUtilsEx.aciiToDefaultEncodeByteArr(strMsg);
         var iCount      = Convert.ToInt32(this.m_textBoxParallelTest4Client.Text);
         Parallel.For(0, iCount, item =>
         {
             this.m_oUDPClientUtils.sendAsync2(strIPRemote, iPortRemote, arrMsg,
                                               (arrByte) =>
             {
                 var strRes = ByteUtilsEx.defaultEncodeByteArrToAciiStr(arrByte);
                 Console.WriteLine("[UDPClientUtils]" + strRes);
             },
                                               (strErrMsg) =>
             {
                 Console.WriteLine(strErrMsg);
             },
                                               (strErrMsg) =>
             {
                 Console.WriteLine(strErrMsg);
             });
         });
     });
 }
Esempio n. 2
0
 private void m_buttonRetryMQTest_Click(object sender, EventArgs e)
 {
     Task.Run(() =>
     {
         var iCount = Convert.ToInt64(this.m_textBoxRetryMQTest.Text);
         Parallel.For(0, iCount, (iIndex) =>
         {
             //invokeDoSth
             var strIPRemote     = this.m_textBoxIPRemote4Send.Text;
             var iPortRemote     = Convert.ToInt32(this.m_textBoxPortRemote4Send.Text);
             var iMsgID          = IDUtilsEx.getInstance().newIdEx();
             var strMsgName      = "name" + iMsgID;
             var oTaskInput      = iMsgID.ToString();
             byte[] arrTaskInput = ByteUtilsEx.aciiToDefaultEncodeByteArr(oTaskInput);
             this.m_oRetryMQ.add(iMsgID, strMsgName, oTaskInput, () =>
             {
                 this.m_oUDPClientUtils.sendAsync2(strIPRemote, iPortRemote, arrTaskInput,
                                                   (arrByte) =>
                 {
                     //invokeDoSthFinish
                     var iMsgIDResp = Convert.ToInt64(ByteUtilsEx.defaultEncodeByteArrToAciiStr(arrByte));
                     this.m_oRetryMQ.update(iMsgIDResp,
                                            (oMsgVo) =>
                     {
                         var oTaskOutput = ByteUtilsEx.defaultEncodeByteArrToAciiStr(arrByte);
                         var oOutVo      = new GenTaskOutputCallbackOutVo()
                         {
                             IsOK       = true,
                             taskOutput = oTaskOutput
                         };
                         return(oOutVo);
                     },
                                            (oMsgVoUpdate) =>
                     {
                         Console.WriteLine("update ui...");
                     });
                 },
                                                   (strErrMsg) =>
                 {
                     throw new Exception(strErrMsg);
                 },
                                                   (strErrMsg) =>
                 {
                     throw new Exception(strErrMsg);
                 });
             });
         });
     });
 }