Exemple #1
0
        /// <summary>
        /// Create a thread worker.
        /// </summary>
        /// <param name="displayText">A text that may be used in messages as a reference for users.</param>
        /// <param name="work">A 'work' delegate. Executed on a separate thread, not the GUI thread.</param>
        /// <param name="complete">A 'complete' delegate. Executed on the original thread, typically the GUI thread.</param>
        public ThreadWorker(ProgressContext progress)
        {
            _worker = new BackgroundWorker();

            _worker.DoWork             += new DoWorkEventHandler(_worker_DoWork);
            _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_worker_RunWorkerCompleted);

            _e = new ThreadWorkerEventArgs(progress);
        }
        /// <summary>
        /// Create a thread worker.
        /// </summary>
        /// <param name="displayText">A text that may be used in messages as a reference for users.</param>
        /// <param name="work">A 'work' delegate. Executed on a separate thread, not the GUI thread.</param>
        /// <param name="complete">A 'complete' delegate. Executed on the original thread, typically the GUI thread.</param>
        public ThreadWorker(ProgressContext progress)
        {
            _worker = new BackgroundWorker();

            _worker.DoWork += new DoWorkEventHandler(_worker_DoWork);
            _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_worker_RunWorkerCompleted);

            _e = new ThreadWorkerEventArgs(progress);
        }
Exemple #3
0
        protected virtual void OnCompleted(ThreadWorkerEventArgs e)
        {
            EventHandler <ThreadWorkerEventArgs> handler = Completed;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemple #4
0
        protected virtual void OnWork(ThreadWorkerEventArgs e)
        {
            EventHandler <ThreadWorkerEventArgs> handler = Work;

            if (handler != null)
            {
                handler(this, e);
            }
        }
		void WorkerCompleted(object sender, ThreadWorkerEventArgs args) {
			BTProgressHUD.Dismiss ();
			if (args.Result == FileOperationStatus.Canceled) {
				Failed();
				return;
			}

			Succeeded(this.targetFilePath);
		}
		void Work(object sender, ThreadWorkerEventArgs args) {
			using (NSAutoreleasePool pool = new NSAutoreleasePool()) {
				string targetDirectory = Path.GetTempPath();
				string extractedFileName = AxCryptFile.Decrypt (
					this.sourceFile, 
					targetDirectory, 
					this.key, 
					AxCryptOptions.None, 
					this.context);

				if (extractedFileName == null) {
					args.Result = FileOperationStatus.Canceled;
					return;
				}

				this.targetFilePath = Path.Combine(targetDirectory,	extractedFileName);
				args.Result = FileOperationStatus.Success;
			}
		}
Exemple #7
0
        /// <summary>
        /// Handles the thread worker completed event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="ThreadWorkerEventArgs"/> instance containing the event data.</param>
        private void HandleThreadWorkerCompletedEvent(object sender, ThreadWorkerEventArgs e)
        {
            if (e.Result.ErrorStatus != ErrorStatus.Success)
            {
                lock (_firstErrorLock)
                {
                    if (FirstError.ErrorStatus == ErrorStatus.Success)
                    {
                        FirstError = e.Result;
                    }
                }
            }
            IDisposable disposable = sender as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
            ReleaseOneConcurrencyRight();
        }
 protected virtual void OnWork(ThreadWorkerEventArgs e)
 {
     EventHandler<ThreadWorkerEventArgs> handler = Work;
     if (handler != null)
     {
         handler(this, e);
     }
 }
 protected virtual void OnCompleting(ThreadWorkerEventArgs e)
 {
     EventHandler<ThreadWorkerEventArgs> handler = Completing;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Exemple #10
0
 private void HandleThreadWorkerCompletedEvent(object sender, ThreadWorkerEventArgs e)
 {
     if (e.Result != FileOperationStatus.Success)
     {
         lock (_firstErrorLock)
         {
             if (FirstError == FileOperationStatus.Success)
             {
                 FirstError = e.Result;
             }
         }
     }
     IDisposable disposable = sender as IDisposable;
     if (disposable != null)
     {
         disposable.Dispose();
     }
     ReleaseOneConcurrencyRight();
 }
 private static void ThreadWorkerEventHandler(object sender, ThreadWorkerEventArgs e)
 {
     e.Result = FileOperationStatus.UnspecifiedError;
 }