/// <summary> /// Updates the status progress. /// </summary> /// <param name="value">The value.</param> /// <param name="statusText">The status text.</param> public void UpdateStatusProgress(int value, string statusText) { try { if (this.OwnerForm.InvokeRequired) { this.OwnerForm.Invoke(_updateStatusProgress, value, statusText); } else { if ((value >= _minimum && value <= _maximum) && (value >= pbarStatus.Minimum && value <= pbarStatus.Maximum)) { pbarStatus.Value = value; } if (statusText.IsEmpty()) { statusText = AsyncProgressMessages.GetMessage(value); } lblStatus.Text = statusText + _elapsedTimer.Elapsed; //Application.DoEvents(); } } catch { } }
/// <summary> /// Initializes the specified callback. /// </summary> /// <param name="callback">The callback.</param> /// <param name="finishedCallback">The finished callback.</param> /// <param name="abortCallback">The abort callback.</param> /// <param name="ownerForm">The owner form.</param> /// <param name="parentForm">The parent form.</param> public void Initialize(IExecutorService executorService, int minimum, int maximum, AsyncWaitCallback callback, AsyncWaitCallback finishedCallback, AsyncWaitCallback abortCallback, Form ownerForm, bool closeOnComplete) { pbarStatus.Style = ProgressBarStyle.Marquee; _elapsedTimer.StopAndStart(); _executorService = executorService; _callback = callback; _finishedCallback = finishedCallback; _abortCallback = abortCallback; this.IsCancellable = (_executorService != null); if (_executorService != null) { IExecutorService2 executor2 = _executorService as IExecutorService2; if (executor2 != null) { executor2.Reset(); } } this.OwnerForm = ownerForm; this.UpdateStatusProgress(0, AsyncProgressMessages.GetMessage(-1)); //Log.LogFormatMessage += new LogFormatMessageHandler(Log_LogFormatMessage); this.CloseOnComplete = closeOnComplete; this.InitializeProgress(minimum, maximum); }