Esempio n. 1
0
        void myWorkerThread_OnThreadError(object source, WorkerThreadEventArgs args)
        {
            intNumThreadsCompleted++;
            if (intNumThreadsCompleted == intNumThreads)
            {
                cmdBegin.Enabled = true;
            }
            string results = string.Format("Error:  Thread {0}\t   Call#: {1}\n{2}",
                                           args.threadname,
                                           args.CallNumber,
                                           args.err.Message);

            lblError.Text = lblError.Text + results + "\n";
            int Threadnum = Convert.ToInt16(args.threadname);

            double dblCallTime = args.MethodCallTime.TotalSeconds;

            CallTimes[Threadnum, args.CallNumber] = dblCallTime;

            decimal decCallTime = Convert.ToDecimal(dblCallTime);

            decCallTime = decimal.Round(decCallTime, 2);
            decimal decAverageTime = Convert.ToDecimal(args.AverageCallTime);

            decAverageTime = decimal.Round(decAverageTime, 2);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.LastCallTime].Text    = decCallTime.ToString();
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.AverageCallTime].Text = decAverageTime.ToString();
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.InCall].Text          = "false";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadStatus].Text    = "Error";
            lsvResults.Items[Threadnum].BackColor = System.Drawing.Color.Goldenrod;
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.Failures].Text = args.numberOfFails.ToString();
            prgCompletedCalls.PerformStep();
        }
Esempio n. 2
0
        void myWorkerThread_OnThreadCompleted(object source, WorkerThreadEventArgs args)
        {
            intNumThreadsCompleted++;
            if (intNumThreadsCompleted == intNumThreads)
            {
                cmdBegin.Enabled = true;
            }

            int    Threadnum          = Convert.ToInt16(args.threadname);
            double dblTotalCallTime   = 0;
            double dblAverageCallTime = 0;

            for (int CallCounter = 0; CallCounter < intCallsPerThread; CallCounter++)
            {
                dblTotalCallTime += CallTimes[Threadnum, CallCounter];
            }
            dblAverageCallTime = dblTotalCallTime / intCallsPerThread;

            decimal decAverageCallTime = Convert.ToDecimal(dblAverageCallTime);

            decAverageCallTime = decimal.Round(decAverageCallTime, 2);
            string strAverageCallTime = string.Format("{0}", dblAverageCallTime);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.InCall].Text          = "false";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadStatus].Text    = "Finished";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.AverageCallTime].Text = decAverageCallTime.ToString();
            lsvResults.Items[Threadnum].BackColor = System.Drawing.Color.DeepSkyBlue;
        }
Esempio n. 3
0
        void myWorkerThread_OnMethodStart(object source, WorkerThreadEventArgs args)
        {
            int Threadnum = Convert.ToInt16(args.threadname);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.InCall].Text     = "true";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.CallNumber].Text = args.CallNumber.ToString();
        }
Esempio n. 4
0
        void myWorkerThread_OnThreadStart(object source, WorkerThreadEventArgs args)
        {
            int Threadnum = Convert.ToInt16(args.threadname);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadID].Text     = args.ThreadID.ToString();
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadStatus].Text = "Running";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.Failures].Text     = args.numberOfFails.ToString();
        }
Esempio n. 5
0
        void myWorkerThread_OnThreadAborted(object source, WorkerThreadEventArgs args)
        {
            intNumThreadsCompleted++;
            if (intNumThreadsCompleted == intNumThreads)
            {
                cmdBegin.Enabled = true;
            }
            int Threadnum = Convert.ToInt16(args.threadname);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.InCall].Text       = "false";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadStatus].Text = "Aborted";
            lsvResults.Items[Threadnum].BackColor = System.Drawing.Color.Yellow;
        }
Esempio n. 6
0
        void myWorkerThread_OnMethodCompleted(object source, WorkerThreadEventArgs args)
        {
            int    Threadnum   = Convert.ToInt16(args.threadname);
            double dblCallTime = args.MethodCallTime.TotalSeconds;

            CallTimes[Threadnum, args.CallNumber] = dblCallTime;

            decimal decCallTime = Convert.ToDecimal(dblCallTime);

            decCallTime = decimal.Round(decCallTime, 2);
            decimal decAverageTime = Convert.ToDecimal(args.AverageCallTime);

            decAverageTime = decimal.Round(decAverageTime, 2);

            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.InCall].Text          = "false";
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.LastCallTime].Text    = decCallTime.ToString();
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.AverageCallTime].Text = decAverageTime.ToString();
            lsvResults.Items[Threadnum].BackColor = System.Drawing.Color.White;
            lsvResults.Items[Threadnum].SubItems[(int)ColumnIndex.ThreadStatus].Text = "Running";

            prgCompletedCalls.PerformStep();
        }
Esempio n. 7
0
        public void BeginThread()
        {
            proxy = new SeahawksClient("Seahawks");
            WorkerThreadEventArgs myargs = new WorkerThreadEventArgs();

            myargs.ThreadID       = Thread.CurrentThread.ManagedThreadId;
            myargs.threadname     = Thread.CurrentThread.Name;
            myargs.ThreadCallTime = TimeSpan.Zero;
            myargs.CallNumber     = 0;
            myargs.err            = null;
            myargs.numberOfFails  = 0;
            if (OnThreadStart != null)
            {
                OnThreadStart(this, myargs);
            }
            rnd = new Random(System.DateTime.Now.Millisecond * Thread.CurrentThread.ManagedThreadId);
            System.DateTime ThreadStartTime = System.DateTime.Now;
            m_TotalCallTime = 0;

            try
            {
                Thread.Sleep(rnd.Next(m_WaitPerCallmin, m_WaitPerCallmax + 1) * 1000);
                for (int intCallCounter = 0; intCallCounter < m_intNumCalls; intCallCounter++)
                {
                    bool methodError = false;
                    myargs.MethodCallTime = TimeSpan.Zero;
                    myargs.err            = null;
                    myargs.CallNumber     = intCallCounter;

                    if (OnMethodStart != null)
                    {
                        OnMethodStart(this, myargs);
                    }

                    System.DateTime MethodStartTime = System.DateTime.Now;
                    TimeSpan        methodcalltime;

                    //*****************************
                    //Make the call

                    try
                    {
                        DoSomething();
                    }
                    catch (Exception ex)
                    {
                        myargs.err = ex;
                        numFailures++;
                        myargs.numberOfFails = numFailures;
                        methodError          = true;

                        methodcalltime         = System.DateTime.Now - MethodStartTime;
                        myargs.MethodCallTime  = methodcalltime;
                        myargs.ThreadCallTime  = (System.DateTime.Now - ThreadStartTime);
                        m_TotalCallTime       += methodcalltime.TotalSeconds;
                        myargs.AverageCallTime = m_TotalCallTime / (intCallCounter + 1);
                        if (OnThreadError != null)
                        {
                            OnThreadError(this, myargs);
                        }
                    }


                    //End Making the call
                    //*****************************

                    if (!methodError)
                    {
                        methodcalltime         = System.DateTime.Now - MethodStartTime;
                        myargs.MethodCallTime  = methodcalltime;
                        myargs.ThreadCallTime  = (System.DateTime.Now - ThreadStartTime);
                        m_TotalCallTime       += methodcalltime.TotalSeconds;
                        myargs.AverageCallTime = m_TotalCallTime / (intCallCounter + 1);
                        if (OnMethodCompleted != null)
                        {
                            OnMethodCompleted(this, myargs);
                        }
                    }

                    if (intCallCounter < m_intNumCalls - 1)
                    {
                        int sleeptime = rnd.Next(m_WaitPerCallmin, m_WaitPerCallmax + 1);
                        Thread.Sleep(sleeptime * 1000);
                    }
                }
                myargs.ThreadCallTime = (System.DateTime.Now - ThreadStartTime);
                if (OnThreadCompleted != null)
                {
                    OnThreadCompleted(this, myargs);
                }
            }

            catch (ThreadAbortException err)
            {
                myargs.ThreadCallTime = (System.DateTime.Now - ThreadStartTime);
                myargs.err            = err;
                if (OnThreadAborted != null)
                {
                    OnThreadAborted(this, myargs);
                }
            }



            catch (Exception err)
            {
                myargs.ThreadCallTime = (System.DateTime.Now - ThreadStartTime);
                myargs.err            = err;
                if (OnThreadError != null)
                {
                    OnThreadError(this, myargs);
                }
            }
        }