Пример #1
0
        /// <summary>
        /// Handler que se utiliza para hacer el work
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProcessActivateBrgWrk_DoWork(object sender, DoWorkEventArgs e)
        {
            //DateTime currentDate;
            //int waitTime;
            //string dateStr;
            //List<Price> argumList = e.Argument as List<Price>;
            // DoWorkLoadParams dwParams = e.Argument as DoWorkLoadParams;
            LogProcess logProc = e.Argument as LogProcess;

            BackgroundWorker worker = (BackgroundWorker)sender;

            while (!worker.CancellationPending)
            {
                int maxTimeWaiting  = Convert.ToInt32(txtTimeWait.Text);
                ProcessSimulator ps = new ProcessSimulator(maxTimeWaiting);
                ps.MaxTimeDuration     = Convert.ToInt32(txtTimeWait.Text);
                logProc.ProcessExecute = ps;
                logProc.DtInic         = DateTime.Now;
                Thread.Sleep(ps.RealTimeDuration * 1000);
                logProc.DtFin = DateTime.Now;
                //dateStr = currentDate.ToString("dd/MM/yyyy HH:mm:ss");
                e.Result = logProc;                // esto es para que en el evento progress changed poder atrapar
                                                   // en el metodo ProcessActivateBrgWrk_RunWorkerCompleted
                worker.ReportProgress(0, logProc); // hace que se dispare el evento ProgressChanged
                TimeSpan ts = logProc.DtFin - logProc.DtInic;
                logProc.WaitTime = this.timeWaitLoading - ts.Seconds;
                if (logProc.WaitTime <= 0)
                {
                    logProc.WaitTime = 0;    // espere 1 seg
                }
                int miliSecs = logProc.WaitTime * 1000;
                Thread.Sleep(miliSecs);
            }
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pProcessExecute"></param>
 public LogProcess(ProcessSimulator pProcessExecute)
 {
     this.ProcessExecute = pProcessExecute;
     this.DtFin          = this.DtInic = DateTime.Now;
 }