/// <summary> /// 刷新界面函数 /// </summary> private void refreshReceive() { if (this.textBoxReceive.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(refreshReceive); this.Invoke(fc);//通过代理调用刷新方法 } else { if (receiveBytes == null || receiveBytes.Length == 0 || receiveShowCount >= receiveBytes.Length) { return; } if (checkBoxAutoClear.Checked && textBoxReceive.Text.Length > 50000) { textBoxReceive.Clear(); } DateTime now_time = DateTime.Now; TimeSpan span = now_time.Subtract(laseTime); laseTime = now_time; if (span.TotalMilliseconds > 50) { textBoxReceive.Text += "\r\n[" + now_time.ToString("HH:mm:ss.fff") + "] "; } int need_show_count = receiveBytes.Length - receiveShowCount; byte[] need_show = new byte[need_show_count]; Array.Copy(receiveBytes, receiveShowCount, need_show, 0, need_show_count); appendReceiveBytes(need_show, need_show_count); } }
private void ThreadFunction() { if (_logListBox.InvokeRequired)//等待异步 { try { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } catch { } } else { if (_logList.Count <= 0) { return; } if (_logListBox.Items.Count * _logListBox.ItemHeight > _logListBox.Height) { _logListBox.Items.Clear(); } _logListBox.BeginUpdate(); _logListBox.Items.Add(_logList.Dequeue()); _logListBox.EndUpdate(); } }
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { bool received = false; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletonFrame.CopySkeletonDataTo(this.skeletonData); received = true; } } if (received) { // 重绘整个画面,冲掉原有骨骼图像 skeletonImage.Draw(new Rectangle(0, 0, skeletonImage.Width, skeletonImage.Height), new Bgr(0.0, 0.0, 0.0), -1); DrawSkeletons(skeletonImage, 0); imageBox1.Image = skeletonImage; FlushClient fc = new FlushClient(ShowIn12Label);//多线程 fc.BeginInvoke(null, null); } }
private void Flash_Yellow_LED() { // 灯是否要变 if (toggle_light) { if (this.pictureBox_LED.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(Flash_Yellow_LED); this.Invoke(fc);//通过代理调用刷新方法 } else { if (0 == yellow_toggle) { pictureBox_LED.Image = imageList1.Images[3]; yellow_toggle = 1; } else { pictureBox_LED.Image = imageList1.Images[0]; yellow_toggle = 0; } } } }
private void ThreadHttpFunction() { if (this.rbVingcard.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); //通过代理调用刷新方法 } else { try { while (CsConst.MyHttpQueue != null && CsConst.MyHttpQueue.Count > 0) { //bIsBusyShowing = true; #region String sPostSms = CsConst.MyHttpQueue.Dequeue(); rbVingcard.AppendText(DateTime.Now.ToShortTimeString() + ":" + sPostSms); rbVingcard.AppendText("\r\n"); Byte[] tmpSendBuf = new Byte[] { 1, 255 }; CsConst.mySends.AddBufToSndList(tmpSendBuf, 0xE01C, 1, 1, false, false, false, false); #endregion } //bIsBusyShowing = false; } catch { } } }
private void UpdateListData(ILoggerData data) { if (this.dgvLogs.InvokeRequired) { FlushClient fc = new FlushClient(UpdateListData); this.Invoke(fc, data); } else { if (data.Method != "OPTIONS") { if (!_successCodes.Contains(data.StatusCode)) { data.Result = OperationResult.Error; niErrors.BalloonTipTitle = "Error"; niErrors.BalloonTipIcon = ToolTipIcon.Error; niErrors.BalloonTipText = $"An error happened on [{data.Method}]{data.Url}."; niErrors.ShowBalloonTip(10000); } _loggerDatas.Add(data); if (data.Result == OperationResult.Error || !_onlyError) { var rowId = dgvLogs.Rows.Add(); dgvLogs.Rows[rowId].Cells[0].Value = data.ID; dgvLogs.Rows[rowId].Cells[1].Value = data.Method.ToUpper(); dgvLogs.Rows[rowId].Cells[2].Value = data.Url; dgvLogs.Rows[rowId].Cells[3].Value = data.Result; dgvLogs.Rows[rowId].Cells[4].Value = data.StatusCode; } } } }
private void Form1_Load(object sender, EventArgs e) { KillRainfallProcess(); string comX = CINIFile.IniReadValue("基本信息", "串口编号", paths.baseInfoPath); Initialize(comX); FlushClientEvent += new FlushClient(Form1_FlushClientEvent); }
private delegate void FlushClient();//代理 public string update_serverDialog(string msg) { FlushClient stcb = new FlushClient(RequestUpdate); Invoke(stcb); //label3.Text = "服务器状态关闭"; //MessageBox.Show(request); return(label3.Text); }
private void ChangeFormCursor(Cursor cursor) { if (this.InvokeRequired) { FlushClient client = new FlushClient(ChangeFormCursor); this.Invoke(client, cursor); } else { this.Cursor = cursor; } }
private void ChangeIPLabel() { if (this.InvokeRequired) { FlushClient client = new FlushClient(ChangeIPLabel); this.Invoke(client); } else { lbl_loc.Text = ResourceCulture.GetLocationString(LoginStatus.UserIP); } }
private void ThreadFunction() { if (this.label3.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { this.label3.Text = timingGo; } }
private void set_tool_status_text() { if (this.tool_status_probar.Control.InvokeRequired) { FlushClient fc = new FlushClient(set_tool_status_text); this.Invoke(fc); } else { this.tool_status_text.Text = this.tool_status_probar.Value + "/" + this.tool_status_probar.Maximum; } }
private void set_tool_probar() { if (this.tool_status_probar.Control.InvokeRequired) { FlushClient fc = new FlushClient(set_tool_probar); this.Invoke(fc); } else { this.tool_status_probar.Value = STATUS_SPIDER_VALUE; } }
private void TextboxFZ3(string str) { if (this.txt_packbar.InvokeRequired) { FlushClient fc = new FlushClient(TextboxFZ3); this.Invoke(fc, str); //通过代理调用刷新方法 } else { this.txt_packbar.Text = str; } }
private void set_task_len() { if (this.tool_status_probar.Control.InvokeRequired) { FlushClient fc = new FlushClient(set_task_len); this.Invoke(fc); } else { this.tool_status_probar.Maximum = TASK_LEN; } }
private void ThreadFunction() { if (this.districtTreeView.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { initDistrictTreeRoot(); } }
/// <summary>设置状态栏 任务信息 /// /// </summary> private void set_tool_status_spider() { if (this.tool_status_probar.Control.InvokeRequired) { FlushClient fc = new FlushClient(set_tool_status_spider); this.Invoke(fc); } else { this.tool_status_spider.Text = STATUS_TEXT; } }
private void ThreadFunction() { if (this.dgrdvPublic.InvokeRequired) //等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { this.LoadPublicData(); } }
/* * Upload file via Ymodem protocol to the device * ret: is the transfer succeeded? true is if yes */ private void ThreadFunction() { if (this.txb_section.InvokeRequired) //等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); //通过代理调用刷新方法 } else { this.txb_section.Text = packetNumber.ToString(); pgb_download.Value = (int)(((float)packetNumber / (float)fsLen) * 100); } }
public void ThreadFunction(string files) { if (this.webControl1.InvokeRequired) { FlushClient fs = new FlushClient(ThreadFunction); this.Invoke(fs, new[] { files }); } else { var url = "/task/edit?file=" + files; OpenTask(url); } }
private void ThreadFunction() { if (this.listView1.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { ExeCommand(@".\Programs\" + "hide.exe " + listView1.Items[AppNum].SubItems[2].Text.ToString()); listView1.Items[AppNum].SubItems[2].Text = "OK!"; } }
private void CrossThreadFlush() { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); //通过代理调用刷新方法 while (thread.IsAlive) { //将sleep和无限循环放在等待异步的外面 ThreadFunction(); Thread.Sleep(1); } }
private void ThreadFunction() { if (label2.InvokeRequired) //等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); } else { label2.Text = i.ToString(); } i++; }
private void ThreadFunction() { if (this.textBox1.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { // this.textBox1.Text = DateTime.Now.ToString(); chart1.Series[0].Points.DataBindXY(chart_x_index, delta_height); textBox1.Text = average_db.ToString(); textBox2.Text = stdeval_db.ToString(); } }
private void refreshPicTask() { while (refreshRunning) { if (pictureBoxPid.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(apandDots); pictureBoxPid.Invoke(fc);//通过代理调用刷新方法 Thread.Sleep(100); } else { apandDots(); } } }
//万德行情初始化 private void TDFDataSubmit(List <string> codes) { if (TDFData.DataSourceConfig.IsUseTDFData) { FlushClient a = new FlushClient(() => { foreach (var form in this.hqForm) { form.RefreshTitle(); } }); TDFData.DataCache.GetInstance().Start(() => { this.Invoke(a); }); codes.ForEach(_ => TDFData.DataCache.GetInstance().AddSub(_)); } }
/* * Upload file via Ymodem protocol to the device * ret: is the transfer succeeded? true is if yes */ private void ThreadFunction() { if (this.TxbSection.InvokeRequired) { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); } else { this.TxbSection.Text = packetNumber.ToString(); int completedDownload = (int)(((float)packetNumber / (float)fsLen) * 100); if (fsLen >= packetNumber) { StatusDownloading.Value = completedDownload; } } }
private void ThreadFunction() { if (textBox1.InvokeRequired) { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc); } else { sum++; qian = sum / 1000; bai = sum % 1000 / 100; shi = sum % 100 / 10; ge = sum % 10; textBox1.Text = qian.ToString() + bai.ToString() + "." + shi.ToString() + ge.ToString(); } }
//代理 public void ImgUpdateFunction(Bitmap bmp1, Bitmap bmp2) { if (this.pictureBox1.InvokeRequired && this.pictureBox2.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ImgUpdateFunction); // this.Invoke(fc);//通过代理调用刷新方法 this.Invoke(fc, new object[2] { bmp1,bmp2 }); } else { this.pictureBox1.Image = new Bitmap(bmp1); this.pictureBox1.Refresh(); this.pictureBox2.Image = new Bitmap(bmp2); this.pictureBox2.Refresh(); } }
private void ThreadFunction() { if (this.rchBoard.InvokeRequired)//等待异步 { try { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } catch (Exception e1) { Console.WriteLine(e1); } } else { this.LoadData(); } }
private void AddImgItem(object img) { if (this.switchImage1.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(AddImgItem); this.Invoke(fc, new object[1] { img }); //通过代理调用刷新方法 } else { List <Banner> b = Netease.GetBanner(); foreach (Banner item in b) { switchImage1.AddImageItems(ImageHelper.GetImg(item.imgUrl), item.title); } } }
//代理 private void CrossThreadFlush() { //将代理绑定到方法 FlushClient fc = new FlushClient(ThreadFuntion); this.BeginInvoke(fc);//调用代理 }
//代理 public string update_serverDialog(string msg) { FlushClient stcb = new FlushClient(RequestUpdate); Invoke(stcb); //label3.Text = "服务器状态关闭"; //MessageBox.Show(request); return label3.Text; }
private void AppendMsg() { if (this.txtResult.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(AppendMsg); this.Invoke(fc); //通过代理调用刷新方法 } else { if (!string.IsNullOrEmpty(msg)) { this.txtResult.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:") + msg); this.txtResult.AppendText("\r\n"); this.txtResult.ScrollToCaret(); } } }
public void AysncRunLocalOpera2(FlushClient ThreadFunc) { Thread thread = new Thread(CrossThreadFlush2); thread.IsBackground = true; thread.Start(ThreadFunc); ShowWaiting(); }
private void CrossThreadFlush3(object WorkFunc) { Control.CheckForIllegalCrossThreadCalls = false; FlushClient WorkingThreadFunc = (FlushClient)WorkFunc; FlushClient fc = new FlushClient(WorkingThreadFunc); Thread.Sleep(400); //add it for GIF picture can run. SendOrPostCallback AppCallback = p => { this.BeginInvoke(fc); }; syncContext.Send(AppCallback, this); }
private void CrossThreadFlush(object WorkFunc) { Control.CheckForIllegalCrossThreadCalls = false; FlushClient WorkingThreadFunc = (FlushClient)WorkFunc; FlushClient fc = new FlushClient(WorkingThreadFunc); fc.BeginInvoke(null,null); //this.BeginInvoke(fc); }
//代理 public void ImgUpdateFunction(Bitmap bmp) { if (this.pictureBox1.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ImgUpdateFunction); // this.Invoke(fc);//通过代理调用刷新方法 this.Invoke(fc, new object[1] { bmp }); } else { if (disbmp == 1) { this.pictureBox1.Image = bmp; this.pictureBox1.Refresh(); } } }
private void ThreadFunction() { if (this.textBox2.InvokeRequired)//等待异步 { FlushClient fc = new FlushClient(ThreadFunction); this.Invoke(fc);//通过代理调用刷新方法 } else { this.textBox2.Text = DateTime.Now.ToString(); } }
private void CrossThreadFlush() { FlushClient fc = new FlushClient(ThreadStartCheckFunction); fc.BeginInvoke(null, null); }