private void StartButton_Click(object sender, System.EventArgs e) { ShowProgressDelegate progDel = new ShowProgressDelegate(StartProcess); progDel.BeginInvoke(100, null, null); MessageBox.Show("Done with operation!!"); }
/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _runner = new Runner(this, _job); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); }
/// <summary> /// Constructor for the form /// </summary> public BuildTools(Guid guid, Job job) { InitializeComponent(); _job = job; _googleAnalytics = new GoogleAnalytics(guid); _runner = new Runner(this, _job, _googleAnalytics); undoBT.Visible = false; progress.Visible = false; versionBox.SelectedIndex = 0; GetVersions(); // delegates _appendDelegate = AppendText; _appendRawDelegate = AppendRawText; _disableDelegate = Disable; _enableDelegate = Enable; _showProgressDelegate = ProgressShow; _hideProgressDelegate = ProgressHide; _indeterminateProgressDelegate = ProgressIndeterminate; _progressPercentDelegate = Progress; _updateVersionsDelegate = UpdateVersions; if (File.Exists(Program.CheckUpdate)) { string text = File.ReadAllText(Program.CheckUpdate); if (string.IsNullOrEmpty(text) || text.Trim().ToLower() == "false") { autoUpdateCB.Checked = false; } } Console.WriteLine(guid.ToString()); new Thread(delegate () { _googleAnalytics.SendEvent("Application", "Start"); }).Start(); }
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { //AddItem(e.UserState as FileInfo); ShowProgressDelegate progressDel = new ShowProgressDelegate(AddItem); FileExtensionDelegate extensionDel = new FileExtensionDelegate(extensionsComboBox_SelectedIndexChanged); this.Invoke(progressDel, e.UserState as FileInfo); this.Invoke(extensionDel, sender, e.UserState as EventArgs); }
void _view_StartEvent(object sender, EventArgs e) { ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); _wc = new WorkerClass(_view, showProgress); Thread t = new Thread(new ThreadStart(_wc.RunProcess)); t.IsBackground = true; //make them a daemon - prevent thread callback issues t.Start(); }
private void ShowProgress(int i) { var del = new ShowProgressDelegate(ShowProgress); Device.BeginInvokeOnMainThread(() => // get into GUI thread { progressText.Text = (i * 10).ToString() + "%"; progressBar.Progress = (i / 10.0); }); }
private void TranslateJS() { string fileName = this.resxFileName.Text; // string outputFileName = this.outputFileName.Text; //Load the js file specified // Read the file and display it line by line. string line, str; string delimStr = "\""; char [] delimiter = delimStr.ToCharArray(); string [] split = null; StreamReader inputFile = new StreamReader(fileName); // StreamWriter outputFile = new StreamWriter(outputFileName); //Get the totalno of lines. No way other than reading till end! long totallines = 0; while ((line = inputFile.ReadLine()) != null) { totallines++; } inputFile.Close(); StreamReader inputresxFile = new StreamReader(fileName); ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); long count = 0; object[] pct; pct = new object[1]; while ((line = inputresxFile.ReadLine()) != null) { //Check if the line starts with var count++; int percentTranslated = (int)(count * 100 / totallines); pct[0] = percentTranslated; this.Invoke(showProgress, pct); line.Trim(); if (line.StartsWith("var")) { split = line.Split(delimiter); string resstr = TranslateString(split[1]); split[1] = resstr; str = String.Join("\"", split); } else { str = line; } // outputFile.WriteLine(str); } inputresxFile.Close(); // outputFile.Close(); }
public MainForm() { InitializeComponent(); cboxVer.SelectedIndex = 0; ipAddressControl1.Text = "192.168.56.3"; show = new ShowProgressDelegate(ShowProgress); update = new UpdateProgressDelegate(UpdateProgress); btnNewFolder.Enabled = false; ShowProgress(false); }
internal BuildDomainDlg(Driver driver, string[] tables, string[] views) : this() { this.driver = driver; this.tables = tables; this.views = views; ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); buildModel = new BuildDomain(this, showProgress); }
//在装入窗体的过程中完成准备工作 private void frmSplash_Load(object sender, EventArgs e) { ShowProgress = ShowProgressInForm; CloseSplash = this.Close; if (DoWork != null) { //创建完成系统初始化工作的辅助线程并启动它。 worker = new Thread(new ParameterizedThreadStart(DoWork)); worker.Start(this); //将自身引用作为参数,启动线程 } }
private void CalcSth(int loops) { ShowProgressDelegate spd = (val => pbResult.Value = val); this.BeginInvoke(spd, 0); for (int i = 1; i <= loops; i++) { Thread.Sleep(SleepTime); this.BeginInvoke(spd, i); } }
public string ShowProgress(ProgressBar progressbar, int totalDigits, int digitsSoFar) { progressbar.Maximum = totalDigits; progressbar.Step = 1; progressbar.Value = digitsSoFar; // Show progress asynchronously if (InvokeRequired) { ShowProgressDelegate showProgresss = new ShowProgressDelegate(ShowProgress); BeginInvoke(showProgresss, new object[] { totalDigits, digitsSoFar }); } return(((digitsSoFar * 100) / totalDigits).ToString() + " %"); }
private void ShowProgress(int val) { if (label1.InvokeRequired) { var del = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(del, val); } else { label1.Text = val.ToString(); label1.Refresh(); progressBar1.Value = val; } }
private void ShowProgress(int progress) { //If we're calling on a background thread if (Lbl_Progress.InvokeRequired == true) { var del = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(del, progress); } else { Lbl_Progress.Text = $"{progress}%"; ProgressBar.Value = progress; } }
private void ShowProgress(int i) { //This is hit if a background thread calls ShowProgress() if (lblOutput.InvokeRequired == true) { var del = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(del, new object[] { i }); } else { lblOutput.Text = i.ToString(); pbStatus.Value = i; } }
private void ShowProgress(int i) { // This is hit if a background thread calls ShowProgress() if (label1.InvokeRequired == true) { var del = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(del, new object[] { i });// call ShowProgress but for else case, for different thread } else { label1.Text = i.ToString(); progressBar1.Value = i; } }
public MainForm() { InitializeComponent(); pr = new Progress(this); show = new ShowProgressDelegate(ShowProgress); update = new UpdateProgressDelegate(UpdateProgress); ShowProgress(false,false); //cboxVer.SelectedIndex = 0; addToStatusLog("Init()"); //local folder path string path=""; if (NFSClient.Properties.Settings.Default.DefaultLocalFolder== "home") path = (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) ? Environment.GetEnvironmentVariable("HOME") : Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); else path = NFSClient.Properties.Settings.Default.DefaultLocalFolder; RefreshLocal(path); if (NFSClient.Properties.Settings.Default.ServerName.Length > 0) { //serverListCombo.Items.AddRange(NFSClient.Properties.Settings.Default.ServerName); int i = 0; foreach (string item in NFSClient.Properties.Settings.Default.ServerName) { serverListCombo.Items.Add(item + " (" + NFSClient.Properties.Settings.Default.ServerAddres[i] + "@" + NFSClient.Properties.Settings.Default.DefaultProtocol[i]+ ")"); i++; } server_index = NFSClient.Properties.Settings.Default.lastServerId; serverListCombo.SelectedIndex = server_index; //auto connect if (NFSClient.Properties.Settings.Default.autoConnect) connect(); } else { AddServer firstTime = new AddServer(this,-1); firstTime.StartPosition = FormStartPosition.Manual; firstTime.Location = new Point(this.Location.X + (this.Width - firstTime.Width) / 2, this.Location.Y + (this.Height - firstTime.Height) / 2); firstTime.Show(this); } }
private void ShowProgress(int i) { //On helper thread so invoke on UI thread to avoid //updating UI controls from alternate thread if (this.lblOutput.InvokeRequired == true) { ShowProgressDelegate del = new ShowProgressDelegate(ShowProgress); //this.BeginInvoke executes delegate on thread used by form (UI thread) this.BeginInvoke(del, new object[] { i }); } else //On UI thread so we are safe to update { this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } }
private void BtnReadTh_Click(object sender, EventArgs e) { toolStripStatusLabel.Text = "data reading..."; ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); ws2300bg ws = new ws2300bg(this, showProgress, new object[] { ws2300, config, "T_IN,T_OUT,DEW,H_IN,H_OUT,WIND,W_CHILL,PRESS" }); Thread t = new Thread(new ThreadStart(ws.RunProcess)); t.IsBackground = true; //make them a daemon - prevent thread callback issues btnInTmp.Enabled = false; btnMinMax.Enabled = false; btnRead.Enabled = false; btnReset.Enabled = false; btnReadTh.Enabled = false; btnHistorySave.Enabled = false; t.Start(); }
void ShowProgress(string pi, int totalDigits, int digitsSoFar) { // check if we are in the right thread if (_pi.InvokeRequired == false) { _pi.Text = pi; _piProgress.Maximum = totalDigits; _piProgress.Value = digitsSoFar; } else { // show progress asynchronously ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); this.Invoke(showProgress, new object[] { pi.ToString(), totalDigits, 0 }); } }
public DownloadMNIST() { baseUrl = @"http://yann.lecun.com/exdb/mnist/"; Files = new List<string>(4); Files.Add("t10k-labels-idx1-ubyte.gz"); Files.Add("train-labels-idx1-ubyte.gz"); Files.Add("t10k-images-idx3-ubyte.gz"); Files.Add("train-images-idx3-ubyte.gz"); System.Net.ServicePointManager.DefaultConnectionLimit = 10; showProgress = ShowProgress; downloadFinished = DownloadFinished; InitializeComponent(); buttonOK.IsEnabled = AllDownloaded; }
private void CalcSth(int loops) { ShowThreadDebuggingInfo("Start to calc"); ShowProgressDelegate spd = ShowProgress; // Init progress Invoke(spd, 0); //UpdateProgress(0); // Doesn't work. for (int i = 1; i <= loops; i++) { Thread.Sleep(SleepTime); Invoke(spd, i); //UpdateProgress(i); // Doesn't work. } }
private void tmenuFindTask_Click(object sender, EventArgs e) { //定义一个后台线程用于导出数据操作 this.tmenuAddTask.Enabled = false; this.tmenuExit.Enabled = false; this.tmenuFindTask.Enabled = false; this.tmenuResetTask.Enabled = false; this.tmenuStart.Enabled = false; ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); cAutoFindUpgradeTask aAddTask = new cAutoFindUpgradeTask(this, showProgress); Thread t = new Thread(new ThreadStart(aAddTask.AutoAddTask)); t.IsBackground = true; t.Start(); }
/// <summary> /// 初始化委托 /// </summary> private void initDelegates() { setOnlineDelegate = new EnableDelegate(onLog); enableSendDelegate = new EnableDelegate(onEnableSend); sendRtfDelegate = new SendRtfDelegate(onSendRtfDelegate); sendFileDelegate = new SendFileDelegate(SendFile); receiveRTFDelegate = new ReceiveRTFDelegate(onReceiveRTF); removeClientDelegate = new RemoveClientDelegate(onRemoveClient); askedForReceivingFileDelegate = new AskedForReceivingFileDelegate(onAskedForReceivingFile); stopSendingOrReceivingFileDelegate = new StopSendingOrReceivingFileDelegate(onStopSendingOrReceivingFile); showMessageDelegate = new ShowMessageDelegate(onShowMessage); setProgressDelegate = new SetProgressDelegate(onSetProgress); showProgressDelegate = new ShowProgressDelegate(onShowProgress); updateStatusDelegate = new UpdateStatusDelegate(onUpdateStatus); startTimingDelegate = new StartTimingDelegate(onStartTiming); }
private void ShowProgress(int i) { // On helper thread so invoke on UI thread to avoid // updating UI controls from alternate thread if (lblOutput.InvokeRequired == true) { ShowProgressDelegate del = new ShowProgressDelegate(ShowProgress); // this.BeginInvoke executes delegate on thread used by form (UI thread) this.BeginInvoke(del, new object[] { i }); } else { // On UI thread so we are safe to update this.lblOutput.Text = i.ToString(); this.pbStatus.Value = i; } }
private void ShowProgres(string str) { // 判断是否在线程中访问 if (!textBox1.InvokeRequired) //.InvokeRequired) { // 不是的话直接操作控件 // textBox1.Text = newPos; textBox1.AppendText(str); textBox1.AppendText("\n"); } else { // 是的话启用delegate访问 ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgres); // 如使用Invoke会等到函数调用结束,而BeginInvoke不会等待直接往后走 // this.BeginInvoke(showProgress, new object[] { newPos }); this.BeginInvoke(showProgress, new object[] { str }); } }
private void ShowProgress(int i) { // here we check if the background thread tries to update an element on the // gui thread if yes // we redirect that activity to the ui thread by // reinvocoking showProgress function using this (which is the form) // then everything works as its supposed to be. if (lblProgress.InvokeRequired) { var showProgressDel = new ShowProgressDelegate(ShowProgress); this.Invoke(showProgressDel, new object[]{i}); } else { lblProgress.Text = String.Format("Progress {0} %", i); this.pbStatus.Value = i; } }
Image initialPicture; // After "clear" operation, all graphics replace to this image. public Form1() { InitializeComponent(); basicpicture = paintBox.Image; graphicBMP = new Bitmap(paintBox.Image); initialPicture = basicpicture; // show the color of line by default picSelectedColorOfLine.BackColor = Color.White; // show the color of filling by default picSelectedColorOfBackground.BackColor = Color.White; DELGif = new ShowProgressDelegate(UpdateProgress); // link load gif updater DELImage = new InvertImageDelegate(UpdateImage); // link load paintBox updater // to enable access to controls from another thread // CheckForIllegalCrossThreadCalls = false; }
void ShowProgress(string pi, int totalDigits, int digitsSoFar) { #if THREADING if (this.InvokeRequired) { ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(showProgress, new object[] { pi, totalDigits, digitsSoFar }); } else { piTextBox.Text = pi; piProgressBar.Maximum = totalDigits; piProgressBar.Value = digitsSoFar; } #else piTextBox.Text = pi; piProgressBar.Maximum = totalDigits; piProgressBar.Value = digitsSoFar; #endif } // ShowProgress
private void ShowProgress(int i) { //the if block execute in case a background thread hit here. //background thread if (lblOutput.InvokeRequired == true) { var del = new ShowProgressDelegate(ShowProgress); //Switch from background to GUI (Main) thread //this.BeginInvoke(..) this.BeginInvoke(del, new object[] { i }); } else //Its on GUI thread. { lblOutput.Text = i.ToString(); pbStatus.Value = i; } }
public void StartComm() { //pump updater ShowPumpProgressDelegate showPumpProgress = new ShowPumpProgressDelegate(ShowPumpProgress); pup = new PumpUpdater(this, showPumpProgress); pup.SetPPV(conf.PPV1, conf.PPV2); Thread t1 = new Thread(new ThreadStart(pup.Worker)); //make them a daemon - prevent thread callback issues t1.IsBackground = true; t1.Start(); ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); Client client = new Client(conf.IP, conf.port, conf.Addr, this, showProgress); if (conf.UseWGT) { Thread t = new Thread(new ThreadStart(client.Worker)); //make them a daemon - prevent thread callback issues t.IsBackground = true; t.Start(); } //start MSR process ShowMSRProgressDelegate showMSRProgress = new ShowMSRProgressDelegate(ShowMSRProgress); msr = new MSR(this, showMSRProgress, conf); msr.SetInfo(SelectedStation, 0); if (conf.UseMSR) { Thread t2 = new Thread(new ThreadStart(msr.Worker)); //make them a daemon - prevent thread callback issues t2.IsBackground = true; t2.Start(); } }
private void Historybg(int new_records, int interval, int lastlog_record, DateTime time_lastrecord_tm, double pressure_term) { toolStripStatusLabel.Text = "data reading..."; ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); ws2300bg ws = new ws2300bg(this, showProgress, new object[] { ws2300, config, "HISTORY" }); ws.NewRecords = new_records; ws.Interval = interval; ws.LastLogRecord = lastlog_record; ws.LastRecordDateTime = time_lastrecord_tm; ws.PressureTerm = pressure_term; Thread t = new Thread(new ThreadStart(ws.RunProcess)); t.IsBackground = true; //make them a daemon - prevent thread callback issues btnInTmp.Enabled = false; btnMinMax.Enabled = false; btnRead.Enabled = false; btnReset.Enabled = false; btnReadTh.Enabled = false; btnHistorySave.Enabled = false; t.Start(); }
private void ExportData(string FileName,cGlobalParas.PublishType pType) { cExport eTxt = new cExport(); string tName = this.tabControl1.SelectedTab.Tag.ToString(); DataGridView tmp = (DataGridView)this.tabControl1.SelectedTab.Controls[0].Controls[0].Controls[0]; this.PrograBarTxt.Visible = true; this.PrograBarTxt.Text =rm.GetString ("Info37") + "��" + tName + " " + "0/0"; this.ExportProbar.Visible = true; //����һ����̨�߳����ڵ������ݲ��� ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); cExport eExcel = new cExport(this, showProgress, pType, FileName, (DataTable)tmp.DataSource); Thread t = new Thread(new ThreadStart(eExcel.RunProcess)); t.IsBackground = true; t.Start(); ShowInfo( rm.GetString("Info38"),rm.GetString("Info37")); tName = null; }
// 显示进度条 void ShowProgress(ProgressBar bar,int totalStep, int currentStep) { if (bar.InvokeRequired) { ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); this.BeginInvoke(showProgress,new object[]{bar,totalStep,currentStep}); } else { bar.Maximum = totalStep; bar.Value = currentStep; } }
private void ShowProgress(double fileCompletion, double overallCompletion, double overallSize) { // check the current thread if (progressBar1.InvokeRequired == false) { progressBar1.Maximum = 100; progressBar1.Value = (int)Math.Round(overallCompletion); } else { // show async progress ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); BeginInvoke(showProgress, new object[] { fileCompletion, overallCompletion, overallSize }); } }
void ShowProgress(int totalDigits, int digitsSoFar) { // Make sure we're on the right thread if( !progressBar1.InvokeRequired ) { progressBar1.Maximum = (int)totalDigits; progressBar1.Value = (int)digitsSoFar; } else { // Show progress asynchronously ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); progressBar1.Invoke(showProgress, new object[] { totalDigits, digitsSoFar}); } }
private void tmenuFindTask_Click(object sender, EventArgs e) { //����һ����̨�߳����ڵ������ݲ��� this.tmenuAddTask.Enabled = false; this.tmenuExit.Enabled = false; this.tmenuFindTask.Enabled = false; this.tmenuResetTask.Enabled = false; this.tmenuStart.Enabled = false; ShowProgressDelegate showProgress = new ShowProgressDelegate(ShowProgress); cAutoFindUpgradeTask aAddTask = new cAutoFindUpgradeTask(this, showProgress); Thread t = new Thread(new ThreadStart(aAddTask.AutoAddTask)); t.IsBackground = true; t.Start(); }