private void StartProcess() { if (pbStatus.InvokeRequired) { var startProcess = new StartProcessHandler(StartProcess); this.BeginInvoke(startProcess);//this means this Form invoke it on its own thread } else { this.Refresh(); this.pbStatus.Maximum = _Max; for (int i = 0; i <= _Max; i++) { Thread.Sleep(10); this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } } }
private void StartProcess() { if (pbStatus.InvokeRequired) { var sph = new StartProcessHandler(StartProcess); this.Invoke(sph); } else { this.Refresh(); this.pbStatus.Maximum = _Max; for (int i = 0; i < _Max; i++) { Thread.Sleep(10); this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } } }
private void StartProcess() { if (pbStatus.InvokeRequired) // we are not in the main GUI thread (the code was invoked on from a non-GUI thread) { var del = new StartProcessHandler(StartProcess); // creates a new delegate this.Invoke(del); // invoke the delegate on the main GUI thread ("this" is the form) } else // we are in the main GUI thread { this.Refresh(); this.pbStatus.Maximum = _Max; for (int i = 0; i <= _Max; i++) { Thread.Sleep(10); this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } } }
private void StartProcess() { if (this.pbStatus.InvokeRequired) { StartProcessHandler sph = new StartProcessHandler(StartProcess); this.Invoke(sph); // Form thread (Guid thread) will recall start process but on GUI thread } else { this.Refresh(); this.pbStatus.Maximum = _Max; for (int i = 0; i <= _Max; i++) { Thread.Sleep(10); this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } } }
private void StartProcess() { if (pbStatus.InvokeRequired) { StartProcessHandler startProcessHandler = new StartProcessHandler(StartProcess); Invoke(startProcessHandler); } else { Refresh(); pbStatus.Maximum = _Max; for (int i = 0; i <= _Max; i++) { Thread.Sleep(10); lblOutput.Text = i.ToString(); pbStatus.Value = i; } } }
private void StartProcess() { progressBar1.Maximum = 100; { if (label1.InvokeRequired) { var sph = new StartProcessHandler(StartProcess); this.Invoke(sph); } else { for (int i = 0; i <= 100; i++) { Thread.Sleep(100); progressBar1.Value = i; label1.Text = i.ToString(); label1.Refresh(); } } } }