示例#1
0
        void manager_WorkStatusEvent(object sender, WorkStatusEventArgs e)
        {
            // 2008-10-16: too many messages can cause application to lock up.  We need to
            // apply a filter to make sure we don't cram the message pump.  Explicitly leave
            // this here to prevent this from happen -- in the case if the user set
            // IsSlaveCanRaiseWorkStatus = true.
            if (e.ThreadName != "Main")
            {
                return;
            }

            if (InvokeRequired)
            {
                BeginInvoke(new WorkStatusEventHandler(manager_WorkStatusEvent), sender, e);
                return;
            }

            lock (lockObj)
            {
                //Random r = new Random();
                //Thread.Sleep(r.Next(0, 100));

                Percentage = e.Percentage;
                txtDetails.AppendText(string.Format("{0} - {1}{2}",
                                                    DateTime.Now.ToString("HH:mm:ss.fff"), e.ToString(), Environment.NewLine));
            }
        }
 /// <summary>
 /// Raise the workstatus event by the Slave thread
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void RaiseSlaveWorkerStatus(object sender, WorkStatusEventArgs e)
 {
     if (!isSlaveCanRaiseWorkStatus)
     {
         return;
     }
     RaiseWorkStatus(e.Message, e.ThreadName, e.Index, e.Percentage, e.WorkerThreadType);
 }
        /// <summary>
        /// add or accumulate the total number of operations since last interval.
        /// </summary>
        /// <param name="e"></param>
        public void Add(WorkStatusEventArgs e)
        {
            if (opi < minOpi)
            {
                minOpi = opi;
            }

            if (opi > maxOpi)
            {
                maxOpi = opi;
            }

            lastOpi     = opi;
            averageOpi  = (averageOpi + opi) / 2;
            lastUpdated = DateTime.Now;
        }