Ejemplo n.º 1
0
 public void Update()
 {
     if (_thread != null && _doWorkArgs != null)
     {
         if (RunWorkerCompleted != null)
         {
             RunWorkerCompleted(this, new RunWorkerCompletedEventArgs(_doWorkArgs.Result, _doWorkArgs.Error, _doWorkArgs.IsCanceled));
         }
         _thread = null;
         _doWorkArgs = null;
         _isCanceled = false;
     }
 }
Ejemplo n.º 2
0
        private void OnBackgroundWork(object arg)
        {
            if (DoWork != null)
            {
                var args = new DoWorkEventArgs(arg, () => _isCanceled);

                if (!_isCanceled)
                {
                    try
                    {
                        DoWork(this, args);

                    }
                    catch (System.Exception ex)
                    {
                        args.Error = ex;
                    }
                }

                _doWorkArgs = args;
            }
        }