public void SetProgressValue(int value) { if (progressSynchronize.InvokeRequired) { SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue); Invoke(d, new object[] { value }); } else { progressSynchronize.Value = value; progressSynchronize.Refresh(); } }
/// <summary> /// Thread-safe method for setting the current value of the progress bar. /// </summary> private void SetProgressValue(int value) { if (this.prgUpdate.InvokeRequired) { SetProgressValueCallback prgCallback = new SetProgressValueCallback(SetProgressValue); this.Invoke(prgCallback, new object[] { value }); } else { prgUpdate.Value = value; prgUpdate.Refresh(); } }
/// <summary> /// Set value property of progress bars /// </summary> /// <param name="form">The calling form</param> /// <param name="control"></param> /// <param name="value"></param> public static void SetProgressValue(Form form, ProgressBar control, int value) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (control.InvokeRequired) { SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue); form.Invoke(d, new object[] { form, control, value }); return; } control.Value = value; }
/// <summary> /// Changes the progress value of a progress bar /// </summary> /// <param name="container">The control that contains the control to change</param> /// <param name="control">The control to change</param> /// <param name="val">The new percentage</param> public static void SetProgressValue(Control container, ProgressBar control, int val) { if (container.InvokeRequired) { SetProgressValueCallback d = SetProgressValue; try { container.Invoke(d, new object[] { container, control, val }); } catch (Exception) { } } else { control.Value = val; } }
public void SetProgressValue(ProgressBar dat, int state) { if (state > dat.Maximum || state < dat.Minimum) { return; } // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (dat.InvokeRequired) { SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue); dat.BeginInvoke(new MethodInvoker(() => dat.Value = state)); } else { dat.Maximum = state; } }
private void SetProgressValue(int value) { if (UploadProgress.InvokeRequired) { SetProgressValueCallback spv = new SetProgressValueCallback(SetProgressValue); this.Invoke(spv, value); } else { UploadProgress.Value = value; } }