public static void SetProgressBar(Form form, ProgressBar ctrl, double progress) { if (ProblemFound) { return; } try { if (ctrl.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgressBar); if (form.IsDisposed) { return; } form.Invoke(d, new object[] { form, ctrl, progress }); } else { ctrl.Value = (int)progress; } } catch (Exception) { ProblemFound = true; } }
public Form1() { InitializeComponent(); //synchronizationContext = SynchronizationContext.Current; pbDelegate += PBSetter; SetTextDelegate += SetText; }
private void SetProgress(int total, int current) { if (this.progressBar1.InvokeRequired) { SetProgressCallback delg = new SetProgressCallback(SetProgress); //this.Invole(delg, new ); } }
/** * Start downloading a list of files in the background. * @param Array list List of files (string) * @param List<ProgressBar> progressBars List of form progress bars. * @param List<Label> labels List of form labels. * @param int maxThreads Maximum number of concurrent downloads. * @param SetProgressCallback callback Call this method when the progress of the entire queue needs updating (used for Taskbar progress in most cases). */ public DownloadQueue(Array list, List<ProgressBar> progressBars, List<Label> labels, int maxThreads, SetProgressCallback callback) { _list = list; _maxThreads = maxThreads; _progressBars = progressBars; _labels = labels; _taskbarProgress = callback; DownloadThread.maxConcurrentDownloads = maxThreads; }
private void SetProgress(int progress) { if (progressBarAdd.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { progress }); return; } progressBarAdd.Value = progress; }
private void setProgressValue(int val) { if (this.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(setProgressValue); this.Invoke(d, new object[] { val }); } else { operationProgress.Value = val; } }
private void SetProgressValue(int value) { if (progBarStatus.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgressValue); Invoke(d, new object[] { value }); } else { progBarStatus.Value = value; } }
private void SetProgress(int value) { if (this.pb.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.pb.Invoke(d, new object[] { value }); } else { this.pb.Value = value; } }
private void SetProgress(double progress) { if (progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { progress }); } else { progressBar1.Value = (int)(progressBar1.Maximum * progress); } }
void OnSetProgressEvent(int d) { if (this.InvokeRequired) { SetProgressCallback a = new SetProgressCallback(OnSetProgressEvent); this.Invoke(a, new object[] { d }); } else { this.progressBar1.Value = d; } }
public void SetProgress(int progress) { if (this.progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { progress }); } else { this.progressBar1.Value = progress; } }
private void ProgressSet(int v) { if (this.LoadProgress.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(ProgressSet); this.Invoke(d, new object[] { v }); } else { LoadProgress.Value = v; } }
//public void WorkerThread_DoWork(object sender, DoWorkEventArgs e) //{ // MessageBox.Show("Sender= " + sender); // keeprunning = true; private void SetProgressStatusValue(int progress) { if (this.prgStatus.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgressStatusValue); this.Invoke(d, new object[] { progress }); } else { this.prgStatus.Value = progress; } }
public static void SetProgress(ProgressBar bar, int value) { if (bar.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); Program.MainForm.Invoke(d, new object[] { bar, value }); } else { bar.Value = value; } }
public void SetProgress(int percent) { if (this.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { percent }); } else { this.progress.Value = percent; this.percentLabel.Text = percent.ToString() + "%"; } }
public void SetProgress(int progress) { // 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 (this.progressBarMain.InvokeRequired) { SetProgressCallback progressCallback = new SetProgressCallback(SetProgress); this.Invoke(progressCallback, new object[] { progress }); } else { this.progressBarMain.Value = progress; } }
private void SetProgress(double current, int max) { if (InvokeRequired) { var callback = new SetProgressCallback(SetProgress); Invoke(callback, current, max); } else { pgbProgress.Maximum = max; pgbProgress.Value = (int)current; Helper.TaskBarProgress.SetState(Handle, Helper.TaskBarProgress.TaskbarStates.Normal); Helper.TaskBarProgress.SetValue(Handle, (int)current, max); } }
public void SetProgress(int Completed, int Total) { if (Progress.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); Invoke(d, new object[] { Completed, Total }); } else { Progress.Maximum = Total; Progress.Value = Completed; groupBox.Text = string.Format("{0}/{1} complete", Completed, Total); } }
public void SetProgress(int val) { if (this.progressBar1.InvokeRequired) { if (!this.progressBar1.IsDisposed) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { val }); } } else { this.progressBar1.Value = val; } }
private void SetProgress(int progress) { // 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 (progressBar1.InvokeRequired) { var d = new SetProgressCallback(SetProgress); Invoke(d, new object[] { progress }); } else { progressBar1.Value = progress; } }
private void SetProgress(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 (this.PrintProgress.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { value }); } else { this.PrintProgress.Value = value; } }
private void SetProgress(int progress) { // 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 (this.Status.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { progress }); } else { this.Progress.Value = progress; } }
public void SetProgress(int completed, int total) { if (Progress.InvokeRequired) { SetProgressCallback d = SetProgress; Invoke(d, new object[] { completed, total }); } else { Progress.Maximum = total; Progress.Value = completed; groupBox.Text = string.Format("{0}/{1} complete", completed, total); } }
private void SetProgress(double percentage) { // 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 (this.textBox1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { percentage }); } else { this.progressBar2.Value = int.Parse(Math.Truncate(percentage).ToString()); } }
public void UpdateProgress(double progress) { // 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 (this.uploadProgressBar.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(UpdateProgress); this.Invoke(d, new object[] { progress }); } else { int as_pct = (int)Math.Round(progress * 100); this.uploadProgressBar.Value = as_pct; } }
private void UpdateProgress(int current) { try { if (updateBar.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(UpdateProgress); Invoke(d, new object[] { current }); } else { updateBar.Maximum = General.MissingMods.Count; updateBar.Text = current.ToString() + "|" + General.MissingMods.Count.ToString(); updateBar.Value = current; } } catch { } }
/// <summary> /// Threadsafe way to invoke progress updates /// </summary> /// <param name="value"></param> private void SetProgress(int value) { if (this.progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); try { this.Invoke(d, new object[] { value }); } catch (ObjectDisposedException) { //Do Nothing } } else { while (vlcControl.GetCurrentMedia() == null) { } if (vlcControl.GetCurrentMedia().Duration.TotalMilliseconds < 10000) { if (value >= 100) { this.progressBar1.Value = 100; this.progressBar1.Value = 99; this.progressBar1.Value = 100; } else if (value <= 0) { this.progressBar1.Value = 0; } else { this.progressBar1.Value = value + 1; this.progressBar1.Value = value; } } else { this.progressBar1.Value = value; } } }
private void SetValue(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 (this.pbS.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetValue); try { this.Invoke(d, new object[] { value }); } catch (Exception) { } } else { this.pbS.Value = value; } }
private void SetProgress(int progress, ProgressBar pb, TabPage page, Button stopBtn, Label label) { try { if (pb.InvokeRequired) { var delgt = new SetProgressCallback(SetProgress); Invoke(delgt, new object[] { progress, pb, page, stopBtn, label }); } else { pb.Value = progress; } if (progress == 100) { page.Controls.Remove(label); page.Controls.Remove(pb); page.Controls.Remove(stopBtn); } } catch (Exception ex) { Utils.Instance.MessageBoxDebug("SetProgress: " + ex.ToString()); } }
public static void SetProgress(Form form, ProgressBar progressBar1, int Maximum, int current) { // 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 (progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); form.Invoke(d, new object[] { form, progressBar1, Maximum, current }); } else { progressBar1.Maximum = Maximum; if (progressBar1.Value + current <= progressBar1.Maximum) { progressBar1.Value += current; } else { progressBar1.Value = progressBar1.Maximum; } progressBar1.Refresh(); } }
// Thread-safe update of progress bar value private void SetProgress(int progress) { if (this.progressBarForm.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.progressBarForm.Invoke(d, new object[] { progress }); } else { this.progressBarForm.SetProgress(progress); } this.progressBarForm.SetProgress(progress); }
/// <summary> /// /// Нарисовать фрактал /// </summary> private void renderFractal() { double resizeMultiplier = 1.1; int threadSleepTimeOut = 10; bool resized = false; int max_x = 0; int max_y = 0; int t; float addenda = 0.0F; mtxImage.WaitOne(); fractalImage = new Bitmap((int)(this.Width * resizeMultiplier), (int)(this.Height * resizeMultiplier)); int num = (this.Width < this.Height) ? this.Width : this.Height; mtxImage.ReleaseMutex(); while (true) { mtxImage.WaitOne(); mtxBool.WaitOne(); if (!renderThreadRunning) { mtxImage.ReleaseMutex(); Thread.Sleep(10); mtxBool.ReleaseMutex(); continue; } mtxBool.ReleaseMutex(); addenda += 0.01F; resized = false; if (fractalImage.Size.Height < this.Height || fractalImage.Width < this.Width || fractalImage.Size.Height > this.Height / 2 || fractalImage.Size.Width> this.Width / 2) { fractalImage.Dispose(); fractalImage = null; fractalImage = new Bitmap((int)(this.Width * resizeMultiplier), (int)(this.Height * resizeMultiplier)); resized = true; } // rendering goes here max_x = fractalImage.Size.Width; max_y = fractalImage.Size.Height; float a; float b; int n; float w = 4F; int itx = max_x; int ity = max_y; int[,] cmp = new int[2, 2]; SetProgressCallback spc = new SetProgressCallback(SetProgress); for (int x = 1; x < itx; x++) { for (int y = 1; y < ity; y++) { a = (float) x * w / itx - w / 2; b = (float) y * w / ity - w / 2; n = computePointNewton(new complex(a, b), addenda); fractalImage.SetPixel(x, y, Color.FromArgb(n % 256, (3 * n + 25) % 256, (int) (4 * n + 10) % 256)); } try { this.Invoke(spc, new object[] { (int)((float)x / max_x * 100) }); } catch (Exception) { // если форма успела сдохнуть, то и хрен с ней mtxImage.ReleaseMutex(); return; } } mtxImage.ReleaseMutex(); if (resized) this.Invalidate(); Thread.Sleep(threadSleepTimeOut); } }
private void SetProgress(int progress) { if (progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); this.Invoke(d, new object[] { progress }); } else { progressBar1.Minimum = 0; progressBar1.Maximum = m_remuxCount; if (progress > 0 && progress < m_remuxCount) { progressBar1.Value = progress; try { TimeSpan elapsed = DateTime.Now - m_startTime; int curSecond = Convert.ToInt32(elapsed.TotalSeconds); if (curSecond > 5 && curSecond != m_lastSecond) // don't update more frequently than each second { m_lastSecond = curSecond; double secPerTick = elapsed.TotalSeconds / progress; double remainingSec = secPerTick * (m_remuxCount - progress); TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(remainingSec)); string remaining = ""; int hours = Convert.ToInt32(Math.Round(ts.TotalHours)); int minutes = Convert.ToInt32(Math.Round(ts.TotalMinutes)); //int seconds = Convert.ToInt32(Math.Round(ts.TotalSeconds)); if (hours > 1) remaining = "About " + hours.ToString() + " hours"; else if (hours == 1 && minutes > 52) remaining = "About an hour"; else if (minutes > 1) remaining = "About " + minutes.ToString() + " minutes"; else if (minutes == 1) remaining = "About a minute"; else remaining = "Less than a minute"; remaining += " left"; label11.Text = remaining; } Application.DoEvents(); } catch { } } } }
public static extern void InitDllWork(SerialProcCallback _SerialProcCallback, SetProgressCallback _SetProgressCallback);
public void SetProgress(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 (this.progressBar1.InvokeRequired) { SetProgressCallback d = new SetProgressCallback(SetProgress); try { this.Invoke(d, new object[] { value }); } catch { } } else { this.progressBar1.Value = value; } }