Beispiel #1
0
        private void btnBadPayload_Click(object sender, EventArgs ea)
        {
          var client = new JokeContractClient(cbo.Text);

          try
          {
            var bad = new BadClass();
            bad.Click += btnBadMsg_Click;
            var echoed = client.ObjectWork(bad);
            Text = echoed.ToString();
          }
          catch (Exception e)
          {
            Text = e.ToMessageWithType();
          }

          client.Dispose();
        }
Beispiel #2
0
        private void btnSimpleWork_Click(object sender, EventArgs e)
        {
            warmup();
            var marshal = chkArgsMarshalling.Checked;            
            Text = "Working...";
            tbNote.Text = "Started...";
            var w = Stopwatch.StartNew();
            
               var node = cbo.Text;
               //var totalCalls = tbCallsPerReactor.Text.AsInt();

               var rcount = tbReactors.Text.AsInt(10);
               var prc = tbCallsPerReactor.Text.AsInt();//totalCalls / rcount;
               var auth = new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text));

               var totalCalls = rcount * prc; 
                
                    var calls = new ConcurrentQueue<Call>();
                    var derrors = new ConcurrentQueue<string>();
                    var tasks = new List<Task>();

                    for(var i=0; i<rcount; i++)
                    {
                      tasks.Add(Task.Factory.StartNew((idx)=>
                      {
                            var lcl = new JokeContractClient(node);
                            lcl.DispatchTimeoutMs = 5 * 1000;
                            lcl.TimeoutMs = 40 * 1000;           
                            lcl.ReserveTransport = true;  

                            for(var j=0; j<prc;j++)
                            {
                              try { calls.Enqueue( new Call( marshal ? lcl.Async_SimpleWorkMar("Call number {0} ".Args(j), j, i, true, 123.12) 
                                                                      : lcl.Async_SimpleWorkAny("Call number {0} ".Args(j), j, i, true, 123.12)) ); }
                              catch (Exception err) 
                              {
                                derrors.Enqueue( "{0}: {1}\r\n".Args(j, err.ToMessageWithType()) ); 
                              }
                            }//for

                            lcl.Dispose();

                      }, i, TaskCreationOptions.LongRunning));

                    }

                Task.WaitAll(tasks.ToArray());
   
                string estr = null;
                while(derrors.TryDequeue(out estr)) tbNote.Text += estr;


                var reactor = new CallReactor( calls );

            var callsPlaced = w.ElapsedMilliseconds;

                reactor.Wait();


                var stats = new ConcurrentDictionary<CallStatus, int>();
                
                     foreach(var call in reactor.Calls)
                     {
                        if (call.CallSlot.CallStatus==CallStatus.ResponseError)
                        {
                            var msg = call.CallSlot.ResponseMsg;
                            Text = msg.ExceptionData.Message;
                        }
                        stats.AddOrUpdate(call.CallSlot.CallStatus, 1, (_,k)=> k+1); 
                     }

                var sb = new StringBuilder();
                foreach(var k in stats.Keys)
                 sb.AppendLine( "{0} = {1} times".Args(k, stats[k]) );

                tbNote.Text += sb.ToString();

            var allFinished = w.ElapsedMilliseconds;

            Text = "Placed {0:n2} calls in {1:n2} ms, then waited {2:n2} ms for finish, total time {3:n2} ms @ {4:n2} calls/sec "
                   .Args
                   (
                     totalCalls,
                     callsPlaced, 
                     allFinished - callsPlaced,
                     allFinished,
                     totalCalls / (allFinished / 1000d)
                   );
        }
Beispiel #3
0
        private void btnReactor2_Click(object sender, EventArgs e)
        {
              var client1 = new JokeContractClient(cbo.Text);
              var client2 = new JokeContractClient(cbo.Text);

                
                    new CallReactor(false,
                        finishedReactor => 
                        {
                           client1.Dispose(); 
                           client2.Dispose();
                           Invoke( (Action)( () => MessageBox.Show(finishedReactor.Context.ToString()) ) );
                        },
                        string.Empty,
                        new Call( client1.Async_Echo("One."),  (reactor, call) => reactor.Context = ((string)reactor.Context) + call.CallSlot.GetValue<string>()),
                        new Call( client2.Async_Echo("Two."),  (reactor, call) => reactor.Context = ((string)reactor.Context) + call.CallSlot.GetValue<string>()),
                        new Call( client1.Async_Echo("Three."),(reactor, call) => reactor.Context = ((string)reactor.Context) + call.CallSlot.GetValue<string>())
                    );

        }
Beispiel #4
0
        private void button4_Click(object sender, EventArgs ea)
        {
          var CNT = edRepeat.Text.AsInt();
         
          var client = new JokeContractClient(cbo.Text);
          
         // client.ReserveTransport = true;
          var w = Stopwatch.StartNew();
          int i = 0;
          try
          {
            for(; i<CNT; i++)
              client.Notify("Notify!");

            w.Stop();
            Text = "Notified  "+CNT.ToString()+" in " + w.ElapsedMilliseconds + " ms";
          }
          catch (Exception e)
          {
            Text = string.Format("After {0} times: {1}", i, e.ToMessageWithType());
          }          

          client.Dispose();
        }
Beispiel #5
0
        private void button3_Click(object sender, EventArgs ea)
        {
          NOTIFY_COUNT++;

          var client = new JokeContractClient(cbo.Text);

          try
          {
            client.Notify("Notify!");
            Text = "Notified " + NOTIFY_COUNT.ToString() + " times";
          }
          catch (Exception e)
          {
            Text = e.ToMessageWithType();
          }          
         
          client.Dispose();
        }
Beispiel #6
0
        private void button2_Click(object sender, EventArgs ea)
        {
          var CNT = edRepeat.Text.AsInt();
         
          var client = new JokeContractClient(cbo.Text);

          client.Headers.Add( new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text)) );
          
        //  client.ReserveTransport = true;
          var w = Stopwatch.StartNew();

          try
          {
            if (chkUnsecureEcho.Checked)
            {
                for(int i=0; i<CNT; i++)
                 client.UnsecureEcho("Hello!");
            }
            else
            {
               for(int i=0; i<CNT; i++)
                 client.Echo("Hello!");
            }

            w.Stop();
            Text = "Echoed  "+CNT.ToString()+" in " + w.ElapsedMilliseconds + " ms";
          }
          catch (Exception e)
          {
            Text = e.ToMessageWithType();
          }
          
          client.Dispose();
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs ea)
        {
          ECHO_COUNT++;

          var client = new JokeContractClient(cbo.Text);
          
          client.Headers.Add( new AuthenticationHeader( new IDPasswordCredentials(tbID.Text, tbPwd.Text)) );

          
          try
          {
            var echoed = chkUnsecureEcho.Checked ? client.UnsecureEcho("Hello!") : client.Echo("Hello!");
            Text = echoed + "  " + ECHO_COUNT.ToString() + " times";
          }
          catch (Exception e)
          {
            Text = e.ToMessageWithType();
          }

          client.Dispose();
        }