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;
     }
 }
        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;
            }
        }