Exemple #1
0
        /// <summary>Starts execution of a background operation.</summary>
        /// <param name="argument">A parameter for use by the background operation to be executed in the <see cref="E:System.ComponentModel.BackgroundWorker.DoWork" /> event handler. </param>
        /// <exception cref="T:System.InvalidOperationException">
        ///   <see cref="P:System.ComponentModel.BackgroundWorker.IsBusy" /> is true. </exception>
        public void RunWorkerAsync(object argument)
        {
            if (IsBusy)
            {
                throw new InvalidOperationException("The background worker is busy.");
            }
            async = AsyncOperationManager.CreateOperation(this);
            ProcessWorkerEventHandler processWorkerEventHandler = ProcessWorker;

            processWorkerEventHandler.BeginInvoke(argument, async, CompleteWorker, null, null);
        }
		public void RunWorkerAsync (object argument)
		{
			if (IsBusy)
				throw new InvalidOperationException ("The background worker is busy.");

			async = AsyncOperationManager.CreateOperation (this);

			complete = false;
			ProcessWorkerEventHandler handler =
				new ProcessWorkerEventHandler (ProcessWorker);
			handler.BeginInvoke (argument, async, CompleteWorker, null, null);
		}