public FloodFillDrawer(PolygonsContainer data, MethodInvoker ImageRefresher = null) { this.ImageRefresher = ImageRefresher; this.data = data; InitializeFloodFillStrategies(); floodFillerStrategy = strategiesList[0]; }
void DetermineCall(MethodInvoker method) { if (!this.IsDisposed && this.InvokeRequired) Invoke(method); else method(); }
private void RaiseOnUiThread(MethodInvoker methodToRaise) { if (synchronizeInvoke.InvokeRequired) synchronizeInvoke.BeginInvoke(methodToRaise, null); else methodToRaise(); }
private void InvokeIfRequired(MethodInvoker _delegate) { if (this.InvokeRequired) this.BeginInvoke(_delegate); else _delegate(); }
public Ping() { this.InitializeComponent(); this.DoUpdateForm = this.UpdateForm; // Create a buffer of 32 bytes of data to be transmitted. this.buffer = Encoding.ASCII.GetBytes(new String('.', 32)); // Jump though 50 routing nodes tops, and don't fragment the packet this.packetOptions = new PingOptions(50, true); this.InitializeGraph(); this.dataGridView1.SuspendLayout(); this.dataGridView1.Columns.Add("1", "Count"); this.dataGridView1.Columns.Add("2", "Status"); this.dataGridView1.Columns.Add("3", "Host name"); this.dataGridView1.Columns.Add("4", "Destination"); this.dataGridView1.Columns.Add("5", "Bytes"); this.dataGridView1.Columns.Add("6", "Time to live"); this.dataGridView1.Columns.Add("7", "Roundtrip time"); this.dataGridView1.Columns.Add("8", "Time"); this.dataGridView1.ResumeLayout(true); }
private void InvokeForm(MethodInvoker mi) { if (InvokeRequired) Invoke(mi); else mi(); }
// Thread-safe operations from event handlers // I love StackOverflow: http://stackoverflow.com/q/782274 public void ThreadSafeDelegate(MethodInvoker method) { if (InvokeRequired) BeginInvoke(method); else method.Invoke(); }
static void Main() { MethodInvoker[] delegates = new MethodInvoker[2]; int outside = 0; for (int i=0; i < 2; i++) { int inside = 0; delegates[i] = delegate { Console.WriteLine ("({0},{1})", outside, inside); outside++; inside++; }; } MethodInvoker first = delegates[0]; MethodInvoker second = delegates[1]; first(); first(); first(); second(); second(); }
public static void InvokeIfNecessary(Control control, MethodInvoker action) { if (control.InvokeRequired) control.Invoke(action); else action(); }
public TraceRouteControl() { InitializeComponent(); this.doUpdateForm = new MethodInvoker(this.UpdateForm); this.InitializeGraph(); }
private void ActualizaProgressBar() { while (true) { MethodInvoker m = new MethodInvoker(() => { int valor = progressBar.Value; if (valor == 100) { valor = 0; } else { ++valor; } progressBar.Value = valor; Thread.Sleep(milisegundos); }); if (progressBar.InvokeRequired) { progressBar.Invoke(m); } else { m.Invoke(); } } }
internal FTeams(ref Common.Interface newCommon) { // // Required for Windows Form Designer support // InitializeComponent(); CommonCode = newCommon; Trace.WriteLine("FTeams: Creating"); EnableMeInvoker = new MethodInvoker(this.enableMe); PopulateTeamsDropDownThreadInvoker += new MethodInvoker(populateTeamsDropDownThread); try { height = this.Size.Height; width = this.Size.Width; } catch(Exception exc) { Trace.WriteLine("FTeams: Exception during creation:" + exc.ToString()); throw; } finally { Trace.WriteLine("FTeams: Created."); } }
/// <summary> /// Calls action on control, invokes if required. /// </summary> /// <param name="control"></param> /// <param name="action"></param> public static void InvokeIfRequired(this Control control, MethodInvoker action) { if (control.InvokeRequired) control.Invoke(action); else action(); }
public void Bind(ArchiveWriter.Stats stats) { onTick = delegate { this.Text = stats.Title; progressBar1.Value = Math.Max(0, Math.Min(100, (int)(stats.Progress * 100))); textStatus.Text = stats.Status; long total = stats.Compressed + stats.SavedByCompression + stats.SavedByInternalDelta + stats.SavedByExternalDelta; TimeSpan time = (stats.EndTime ?? DateTime.Now) - stats.StartTime; labelL1.Text = "Total processed:"; textL1.Text = FormatSize(total); labelL2.Text = "Elapsed time:"; textL2.Text = string.Format("{0}:{1:D2}:{2:D2}", time.Hours, time.Minutes, time.Seconds); labelL3.Text = "Block size:"; textL3.Text = FormatSize(Settings.BlockSize); labelL4.Text = ""; textL4.Text = ""; labelR1.Text = "Compressed size:"; textR1.Text = FormatSize(stats.Compressed, total); labelR2.Text = "Saved by compression:"; textR2.Text = FormatSize(stats.SavedByCompression, total); labelR3.Text = "Saved by internal delta:"; textR3.Text = FormatSize(stats.SavedByInternalDelta, total); labelR4.Text = "Saved by external delta:"; textR4.Text = FormatSize(stats.SavedByExternalDelta, total); buttonCancel.Enabled = (stats.EndTime == null); }; onCancel = delegate { stats.Canceled = true; stats.EndTime = DateTime.Now; }; }
public void Bind(ArchiveReader.Stats stats) { onTick = delegate { this.Text = stats.Title; progressBar1.Value = Math.Max(0, Math.Min(100, (int)(stats.Progress * 100))); textStatus.Text = stats.Status; TimeSpan time = (stats.EndTime ?? DateTime.Now) - stats.StartTime; TimeSpan writeTime = (stats.EndTime ?? DateTime.Now) - (stats.WriteStartTime ?? DateTime.Now); long writeSpeed = (int)writeTime.TotalSeconds == 0 ? 0 : stats.TotalWritten / (int)writeTime.TotalSeconds; labelL1.Text = "Total processed:"; textL1.Text = FormatSize(stats.TotalWritten + stats.Unmodified); labelL2.Text = "Elapsed time:"; textL2.Text = string.Format("{0}:{1:D2}:{2:D2}", time.Hours, time.Minutes, time.Seconds); labelL3.Text = "Average speed:"; textL3.Text = writeSpeed == 0 ? "-" : (FormatSize(writeSpeed) + "/s"); labelL4.Text = ""; textL4.Text = ""; labelR1.Text = "Unmodified:"; textR1.Text = FormatSize(stats.Unmodified, stats.Unmodified + stats.ReadFromArchiveCompressed + stats.ReadFromWorkingCopy); labelR2.Text = "Read from archive:"; textR2.Text = FormatSize(stats.ReadFromArchiveCompressed, stats.Unmodified + stats.ReadFromArchiveCompressed + stats.ReadFromWorkingCopy); labelR3.Text = "Read from working copy:"; textR3.Text = FormatSize(stats.ReadFromWorkingCopy, stats.Unmodified + stats.ReadFromArchiveCompressed + stats.ReadFromWorkingCopy); labelR4.Text = ""; textR4.Text = ""; buttonCancel.Enabled = (stats.EndTime == null); }; onCancel = delegate { stats.Canceled = true; stats.EndTime = DateTime.Now; }; }
private void UpdateState() { MethodInvoker invoker = new MethodInvoker(delegate() { if ((File.GetAttributes(m_originalSolutionFullPath) & FileAttributes.ReadOnly) != 0) { m_labelState.ForeColor = Color.Red; m_labelState.Text = "ReadOnly"; m_labelStateDescription.Visible = true; m_buttonYes.Enabled = false; } else { m_labelState.ForeColor = Color.Black; m_labelState.Text = "Writable"; m_labelStateDescription.Visible = false; m_buttonYes.Enabled = true; } }); if (m_labelState.InvokeRequired) { this.Invoke(invoker); } else { invoker.Invoke(); } }
/// <summary> /// Check to see if an update to the application is available. /// </summary> /// <param name="available">A <see cref="MethodInvoker"/> delegate which is called if an update is available.</param> internal static void CheckAvailable(MethodInvoker available) { ThreadPool.QueueUserWorkItem(delegate { CachedWebClient checkUpdate = CachedWebClient.GetInstance(); string versionInfo = null; try { versionInfo = checkUpdate.DownloadString(new Uri(BaseUrl + Application.ProductVersion), CacheHours); } catch (WebException) { // Temporary problem downloading the information, try again later return; } Settings.LastCheckForUpdates = DateTime.Now; if (!string.IsNullOrEmpty(versionInfo)) { versionInfo = versionInfo.Split(new string[] { "\r\n" }, StringSplitOptions.None)[0]; if (string.Compare(versionInfo, Application.ProductVersion, StringComparison.Ordinal) > 0) { // There is a new version available available(); } } return; }); }
/// <summary> /// Runs a MethodInvoker delegate on the UI thread from whichever thread we are currently calling from and BLOCKS until it is complete /// </summary> /// <param name="ivk"></param> public void UIBlockingInvoke(MethodInvoker ivk) { System.Threading.ManualResetEvent UIAsyncComplete = new System.Threading.ManualResetEvent(false); UIAsyncComplete.Reset(); if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { try { ivk(); } finally { UIAsyncComplete.Set(); } })); UIAsyncComplete.WaitOne(); } else { ivk(); } }
public void Given() { _operation = new FailOnceOperation(); _invoker = new OperationInvoker<string>(_operation); _invoker.Policies.Add(new Retry(null)); _engine = new Dispatcher<string>(); }
/// <summary> /// Load default value to control and other initialize. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MethodInvoker runHitCount = new MethodInvoker(UpdateHitCount); runHitCount.BeginInvoke(CurrentWeb, HttpContext.Current, null, null); //dvBG.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCount.InnerText = HitCountNumber.ToString(); //dvBGDay.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCountDay.InnerText = DayHitCountNumber.ToString(); //dvBGNow.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCountNow.InnerText = CurrentHitCountNumber.ToString(); //dvBGWeek.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCountWeek.InnerText = WeekHitCountNumber.ToString(); //dvBGMonth.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCountMonth.InnerText = MonthHitCountNumber.ToString(); //dvBGYesterday.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;"); //dvHitCountYesterday.InnerText = YesterdayHitCountNumber.ToString(); tdAll.InnerText = HitCountNumber.ToString(); tdToday.InnerText = DayHitCountNumber.ToString(); lblCurrent.Text = "<span id='spCurrent'>" + CurrentHitCountNumber.ToString() + "</span>"; tdThisWeek.InnerText = WeekHitCountNumber.ToString(); tdThisMonth.InnerText = MonthHitCountNumber.ToString(); tdYesterday.InnerText = YesterdayHitCountNumber.ToString(); } }
public static void InvokeIfRequired(this ISynchronizeInvoke control, MethodInvoker action) { if (control.InvokeRequired) control.Invoke(action, null); else action(); }
private void MarshalToForm(MethodInvoker code) { if (m_form.InvokeRequired) m_form.BeginInvoke(code); else code(); }
public static Button add_Button(this Control control, string text, int top, int left, int height, int width, MethodInvoker onClick) { return control.invokeOnThread( () => { var button = new Button {Text = text}; if (top > -1) button.Top = top; if (left > -1) button.Left = left; if (width == -1 && height == -1) button.AutoSize = true; else { if (width > -1) button.Width = width; if (height > -1) button.Height = height; } button.onClick(onClick); /*if (onClick != null) button.Click += (sender, e) => onClick();*/ control.Controls.Add(button); return button; }); }
public override void Execute() { string msg = ""; if (AppContext.IsAppInitializing && AppContext.IsGetSignalList && AppContext.SignalDatas.Count > 0) { signals = new Signal[AppContext.SignalDatas.Count]; AppContext.SignalDatas.CopyTo(signals); MethodInvoker mi = new MethodInvoker(InitPriceList); priceListView.Invoke(mi); mi = new MethodInvoker(InitSignalList); signalListView.Invoke(mi); mi = new MethodInvoker(InitStatList); statListView.Invoke(mi); } else if (AppContext.IsAppInitializing && AppContext.IsGetSymbolPrices && AppContext.SymbolPrices.Count > 0) { MethodInvoker mi = new MethodInvoker(InitPriceList); priceListView.Invoke(mi); AppContext.IsStatListInitialized = true; AppContext.IsSignalListInitialized = true; } else { if (AppSetting.STATUS == AppSetting.TEST_ACCOUNT) // || AppSetting.STATUS == AppSetting.ADMIN_ACCOUNT { msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "2" }); } else { msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "0" }); } Send(msg); } }
public ShortcutAction(Keys k, bool ctrl, bool editorMustBeFocused, MethodInvoker func) { Key = k; Ctrl = ctrl; EditorMustBeFocused = editorMustBeFocused; fMethodInvoker = func; }
private static void InvokeIfRequired(ISynchronizeInvoke control, MethodInvoker action) { if (control.InvokeRequired) control.Invoke(action, new object[0]); else action(); }
private void DeterMineCall(MethodInvoker method) { if (InvokeRequired && !this.IsDisposed) Invoke(method); else method(); }
/// <summary> /// Invokes the passed function if required. /// </summary> /// <param name="action">Function that should be invoked if required.</param> public void InvokeIfRequired(MethodInvoker action) { if (InvokeRequired) Invoke(action); else action(); }
public static Thread StartTry(MethodInvoker code, ErrorHandler on_error = null, MethodInvoker on_finally = null, bool background = true) { Thread t = new Thread( () => { try { code.Invoke(); } catch (ThreadAbortException e) { Thread.ResetAbort(); } catch (Exception e) { if (on_error != null) on_error.Invoke(e); else Message.Error(e); } finally { on_finally?.Invoke(); } } ); t.IsBackground = background; t.Start(); return t; }
public static System.Boolean ClearAllTemporaryStates() { var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.UI.ModelObjectVisualization", "ClearAllTemporaryStates"); return(result); }
private void InvokeOnPreviewThread(MethodInvoker d) { _previewControl.Invoke(d); }
internal void MeasureItems() { int right = 0; int bottom = 0; if (_items == null || _items.Count == 0) { // create a temp bitmap to work with var btm = new Bitmap(10, 10, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var g = Graphics.FromImage(btm); SizeF s = SongListViewItem.MeasureColumn(g, NoResultsString, -1, this.Font); right = Convert.ToInt32(s.Width); bottom = Convert.ToInt32(s.Height); } else { // create a temp bitmap to work with var btm = new Bitmap(10, 10, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var g = Graphics.FromImage(btm); _widestalbum = 0; // just measure the albums first, so we know how wide the widest one is if (_showAlbumArt) { _items.ForEach(delegate(SongListViewItem item) { if (item.IsStartOfNewAlbum) { item.MeasureAlbum(g, 0, 0, _headerFont, this.Font); _widestalbum = Math.Max(_widestalbum, item.AlbumRectangle.Right + 1); } }); } else { _widestalbum = 0; } // now unfortunately we have to remeasure everything, since the albums have moved int y = 0; int lastAlbumBottom = 0; _items.ForEach(delegate(SongListViewItem item) { if (item.IsStartOfNewAlbum) { if (y <= lastAlbumBottom) { y = lastAlbumBottom; } // move this album down a bit from the previous one if (!_flatMode) { y += 10; } item.MeasureAlbum(g, 0, y, _headerFont, this.Font); right = Math.Max(right, item.AlbumRectangle.Right); bottom = Math.Max(bottom, item.AlbumRectangle.Bottom); lastAlbumBottom = item.AlbumRectangle.Bottom; } item.MeasureItem(g, _widestalbum, y, this.Font); y = item.Rectangle.Bottom; right = Math.Max(right, item.Rectangle.Right); bottom = Math.Max(bottom, item.Rectangle.Bottom); }); } MethodInvoker DoWork = delegate { this.AutoScrollMinSize = new Size(right + 10, bottom + 10); }; if (this.InvokeRequired) { Invoke(DoWork); } else { DoWork(); } ItemsMeasured?.Invoke(this, EventArgs.Empty); Invalidate(); }
private void LoadPrepare() { MethodInvoker invoke = new MethodInvoker(LoadPrepare1); BeginInvoke(invoke); }
private void MenuButton_Click(object sender, EventArgs e) { Task ThreadMenu = new Task(() => { //Slow Down Animation When approaching Button. Button[] MenuButtonArray = new Button[] { HomeButton, SearchButton, OrdersButton, adminButton }; // Coppied from Above not making it a Global Variable to prevent any changes if (menuClosed) { while (SideMenuPanel.Width < 139) { Console.WriteLine(SideMenuPanel.Width); MethodInvoker updateIt = delegate { SideMenuPanel.Width = SideMenuPanel.Width + 1; }; SideMenuPanel.BeginInvoke(updateIt); //Add User Control ReSizing Below //Adding a Panel & Then Docking it to the centre removes the need to resize controls as it is handled within the docking. //MethodInvoker UiThread = delegate // { // if (MenuIndicatorPanel.Width > 15) // { // MenuIndicatorPanel.Width += 1; // System.Threading.Thread.Sleep(30); // } // else // { // MenuIndicatorPanel.BackColor = Color.DodgerBlue; // System.Threading.Thread.Sleep(10); // } // }; //MenuIndicatorPanel.BeginInvoke(UiThread); } SideMenuPanel.Size = new Size(139, SideMenuPanel.Height); for (int i = 0; i < 4; i++) { OpenButton(MenuButtonArray[i], MenuButtonNames[i]); } OpenButton(SettingsButton, " Settings"); menuClosed = false; } else { while (SideMenuPanel.Width > CLOSED_PANEL_WDITH) { MethodInvoker updateIt = delegate { SideMenuPanel.Width -= 1; }; SideMenuPanel.BeginInvoke(updateIt); Application.DoEvents(); if (MenuIndicatorPanel.Width != 5) { MethodInvoker updateIt2 = delegate { MenuIndicatorPanel.Width -= 1; }; MenuIndicatorPanel.BeginInvoke(updateIt2); Application.DoEvents(); System.Threading.Thread.Sleep(30); } else { MenuIndicatorPanel.BackColor = Color.Blue; System.Threading.Thread.Sleep(10); } //Add User Control ReSizing Below } menuClosed = true; for (int i = 0; i < 3; i++) { CloseButton(MenuButtonArray[i]); } CloseButton(SettingsButton); } }); ThreadMenu.Start(); }
public void Call(MethodInvoker callDelegate) { Call(callDelegate, false); }
private void doSomthing() { while (true) { int money = 0; if (this.isStop) { return; } try { this.MoneyTextElement = this.chromeWebCrowser.Document.GetElementById(this.MoneyTextID); this.MoneyPlusElement = this.chromeWebCrowser.Document.GetElementById(this.MoneyPlusButtonID); this.MoneySubmitElement = this.chromeWebCrowser.Document.GetElementById(this.MoneySubmitButtonID); if (int.TryParse(this.MoneyTextElement.Value, out money)) { if (money < this.many) { this.MoneyPlusElement.Click(); if (System.Configuration.ConfigurationSettings.AppSettings["needsleep"] == "true") { System.Threading.Thread.Sleep(200); } } MethodInvoker invoker = delegate { this.labMany.Text = this.MoneyTextElement.Value; }; if ((!base.IsDisposed) && base.InvokeRequired) { base.Invoke(invoker); } else { invoker(); } int.TryParse(this.MoneyTextElement.Value, out money); if (money == this.many) { // this.MoneySubmitElement.Click(); MethodInvoker invoker1 = delegate { this.labMany.Visible = false; this.labelX9.Visible = false; this.labelX7.Text = "当前值已达到目标值" + money.ToString() + "万元,已提交"; MessageBox.Show("当前值已达到目标值" + money.ToString() + "万元,已提交"); }; if ((!base.IsDisposed) && base.InvokeRequired) { base.Invoke(invoker1); } else { invoker1(); } break; } if (money > this.many) { MethodInvoker invoker1 = delegate { this.labMany.Visible = false; this.labelX9.Visible = false; this.labelX7.Text = "当前值超过目标值,退出监控"; this.isStop = true; this.btnStart.Enabled = true; this.progressBarX1.Text = "监控已停止..."; this.progressBarX1.ProgressType = DevComponents.DotNetBar.eProgressItemType.Standard; MessageBox.Show("当前值超过目标值,退出监控"); }; if ((!base.IsDisposed) && base.InvokeRequired) { base.Invoke(invoker1); } else { invoker1(); } break; } } } catch { } System.Threading.Thread.Sleep(100); } MethodInvoker invoker2 = delegate { this.isStop = true; this.btnStart.Enabled = true; this.progressBarX1.Text = "监控已停止..."; this.progressBarX1.ProgressType = DevComponents.DotNetBar.eProgressItemType.Standard; this.labelX9.Visible = false; this.labMany.Visible = false; }; if ((!base.IsDisposed) && base.InvokeRequired) { base.Invoke(invoker2); } else { invoker2(); } }
public object Convert(MethodInvoker invoker, Type type, object instance) { return(DateTime.Parse(instance.ToString())); }
public static void ShowCancelRunningFormOn2ndThread() { MethodInvoker mi = new MethodInvoker(ShowCancelRunningForm2); mi.BeginInvoke(null, null); }
static void LogMouseEvent(Object obj, MouseEventArgs e) { Console.WriteLine("LogMouse"); ThreadStart ts = new ThreadStart(MyMethod); ThreadStart ts2 = MyMethod; Thread t = new Thread(ts2); t.Start(); StreamFactory factory = GenerateSampleData; using (Stream stream = factory()) { int data; while ((data = stream.ReadByte()) != -1) { Console.WriteLine(data); } } //======================= EventHandler handler = new EventHandler(LogPlainEvent); KeyPressEventHandler keyHandler = new KeyPressEventHandler(handler); //============== Dervied x = new Dervied(); SampleDelegate fac = new SampleDelegate(x.CandidateAction); fac("TEST!!"); ActionMethod(); //=============================== List <int> intList = new List <int>(); intList.Add(5); intList.Add(10); intList.Add(15); intList.Add(25); intList.ForEach(delegate(int n) { Console.WriteLine(Math.Sqrt(n)); }); //================ Predicate <int> isEven = delegate(int xx) { return(xx % 2 == 0); }; Console.WriteLine(isEven(10)); //SortAndShowFiles("Sort by name:",delegate(FileInfo f1,FileInfo f2) { return f1.Name.CompareTo(f2.Name); }); EnclosingMethod(); CaptureVariable(); Console.WriteLine("//======================="); MethodInvoker xxx = CreateDelegateInstace(); xxx(); xxx(); InitCapturedVariable(); }
public async void Display(string loc, string pre, string suf, int[] indexes, double fps) { while (loading) { waiting = true; await Task.Delay(100); } loading = true; if (waiting) { string[] anim = new string[] { "Reloading", "Reloading.", "Reloading..", "Reloading...", "Reloading..", "Reloading.", "Reloading" }; for (int i = 0; i < anim.Length; i++) { Frames.Text = anim[i]; await Task.Delay(80); } } waiting = false; string[] paths = new string[indexes.Length]; for (int i = 0; i < indexes.Length; i++) { paths[i] = $@"{ loc }\{ pre }{ Indexify( indexes[ i ] ) }{ suf }"; } foreach (Bitmap i in this.images) { if (i != null) { i.Dispose(); } } if (animation != null) { animation.Dispose(); } Bitmap[] images = new Bitmap[paths.Length]; this.images = images; await Task.Factory.StartNew(() => { for (int i = 0; i < paths.Length; i++) { MethodInvoker inv = delegate { Frames.Text = $"{ i } / { images.Length }"; }; Parent.Invoke(inv); Image A = Image.FromFile(paths[i]); images[i] = new Bitmap(A, new Size(Rescale(A, Picture))); A.Dispose(); if (waiting) { return; } } Animate(fps); }); Frames.Text = waiting ? "Reloading..." : $"{ images.Length } ( Loaded )"; loading = false; }
private static void BeginInvoke(MethodInvoker methodInvoker) { throw new NotImplementedException(); }
internal void AddKeyHandler(ConsoleShortcutKey shortcutKey, MethodInvoker methodInvoker) { Program.AssertOnEventThread(); switch (shortcutKey) { case ConsoleShortcutKey.CTRL_ALT: AddKeyHandler(new Set <Keys>(Keys.ControlKey, Keys.Menu), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.LMenu), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.RMenu), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.LMenu), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.RMenu), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN, GR_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN, GR_SCAN), methodInvoker); break; case ConsoleShortcutKey.CTRL_ALT_F: AddKeyHandler(new Set <Keys>(Keys.ControlKey, Keys.Menu, Keys.F), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.LMenu, Keys.F), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.RMenu, Keys.F), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.LMenu, Keys.F), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.RMenu, Keys.F), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT_SCAN, F_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN, F_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN, GR_SCAN, F_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT_SCAN, F_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN, F_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN, GR_SCAN, F_SCAN), methodInvoker); break; case ConsoleShortcutKey.F12: AddKeyHandler(new Set <Keys>(Keys.F12), methodInvoker); AddKeyHandler(new Set <int>(F12_SCAN), methodInvoker); break; case ConsoleShortcutKey.CTRL_ENTER: AddKeyHandler(new Set <Keys>(Keys.ControlKey, Keys.Enter), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.Enter), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.Enter), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ENTER_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ENTER_SCAN), methodInvoker); break; case ConsoleShortcutKey.ALT_SHIFT_U: AddKeyHandler(new Set <Keys>(Keys.Menu, Keys.ShiftKey, Keys.U), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LMenu, Keys.LShiftKey, Keys.U), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LMenu, Keys.RShiftKey, Keys.U), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RMenu, Keys.LShiftKey, Keys.U), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RMenu, Keys.RShiftKey, Keys.U), methodInvoker); AddKeyHandler(new Set <int>(ALT_SCAN, L_SHIFT_SCAN, U_SCAN), methodInvoker); AddKeyHandler(new Set <int>(ALT2_SCAN, L_SHIFT_SCAN, U_SCAN), methodInvoker); AddKeyHandler(new Set <int>(ALT_SCAN, R_SHIFT_SCAN, U_SCAN), methodInvoker); AddKeyHandler(new Set <int>(ALT2_SCAN, R_SHIFT_SCAN, U_SCAN), methodInvoker); AddKeyHandler(new Set <int>(ALT2_SCAN, R_SHIFT_SCAN, GR_SCAN, U_SCAN), methodInvoker); AddKeyHandler(new Set <int>(ALT2_SCAN, L_SHIFT_SCAN, GR_SCAN, U_SCAN), methodInvoker); break; case ConsoleShortcutKey.F11: AddKeyHandler(new Set <Keys>(Keys.F11), methodInvoker); AddKeyHandler(new Set <int>(F11_SCAN), methodInvoker); break; case ConsoleShortcutKey.RIGHT_CTRL: AddKeyHandler(new Set <Keys>(Keys.RControlKey), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN), methodInvoker); break; case ConsoleShortcutKey.LEFT_ALT: AddKeyHandler(new Set <Keys>(Keys.LMenu), methodInvoker); AddKeyHandler(new Set <int>(ALT_SCAN), methodInvoker); break; case ConsoleShortcutKey.CTRL_ALT_INS: AddKeyHandler(new Set <Keys>(Keys.ControlKey, Keys.Menu, Keys.Insert), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.LMenu, Keys.Insert), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.LControlKey, Keys.RMenu, Keys.Insert), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.LMenu, Keys.Insert), methodInvoker); AddKeyHandler(new Set <Keys>(Keys.RControlKey, Keys.RMenu, Keys.Insert), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT_SCAN, INS_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN, INS_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT2_SCAN, GR_SCAN, INS_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN, INS_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL2_SCAN, ALT_SCAN, INS_SCAN), methodInvoker); AddKeyHandler(new Set <int>(CTRL_SCAN, ALT2_SCAN, GR_SCAN, INS_SCAN), methodInvoker); break; } }
/// <summary> /// Loads the data for the specific KPI /// </summary> /// <param name="Overall.SelectedCountry"></param> public void LoadData() { try { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // PR Release vs PO Release // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// foreach (DataRow dr in Overall.prsOnPOsDt.Rows) { string[] strPOLineFirstRelDate = (dr["PO Line 1st Rel Dt"].ToString()).Split('/'); int poLineFirstRelYear = int.Parse(strPOLineFirstRelDate[2]); int poLineFirstRelMonth = int.Parse(strPOLineFirstRelDate[0]); int poLineFirstRelDay = int.Parse(strPOLineFirstRelDate[1]); if (poLineFirstRelYear == 0 && poLineFirstRelMonth == 0 && poLineFirstRelDay == 0) { continue; } else { prRelVsPORel.data.Total++; poLineFirstRelYear = int.Parse(strPOLineFirstRelDate[2]); poLineFirstRelMonth = int.Parse(strPOLineFirstRelDate[0].TrimStart('0')); poLineFirstRelDay = int.Parse(strPOLineFirstRelDate[1].TrimStart('0')); } DateTime poLineFirstRelDate = new DateTime(poLineFirstRelYear, poLineFirstRelMonth, poLineFirstRelDay); string[] strPR2ndLvlRelDate = (dr["PR 2° Rel# Date"].ToString()).Split('/'); int secLvlRelYear = int.Parse(strPR2ndLvlRelDate[2]); int secLvlRelMonth = int.Parse(strPR2ndLvlRelDate[0].TrimStart('0')); int secLvlRelDay = int.Parse(strPR2ndLvlRelDate[1].TrimStart('0')); DateTime pr2ndLvlRelDate = new DateTime(secLvlRelYear, secLvlRelMonth, secLvlRelDay); double elapsedDays = (poLineFirstRelDate - pr2ndLvlRelDate).TotalDays; totalDays += elapsedDays; elapsedDays = (int)elapsedDays; if (elapsedDays <= 0) { prRelVsPORel.data.LessThanZero++; } else if (elapsedDays >= 1 && elapsedDays <= 3) { prRelVsPORel.data.One_Three++; } else if (elapsedDays >= 4 && elapsedDays <= 7) { prRelVsPORel.data.Four_Seven++; } else if (elapsedDays >= 8 && elapsedDays <= 14) { prRelVsPORel.data.Eight_Fourteen++; } else if (elapsedDays >= 15 && elapsedDays <= 21) { prRelVsPORel.data.Fifteen_TwentyOne++; } else if (elapsedDays >= 22 && elapsedDays <= 28) { prRelVsPORel.data.TwentyTwo_TwentyEight++; } else if (elapsedDays >= 29 && elapsedDays <= 35) { prRelVsPORel.data.TwentyNine_ThirtyFive++; } else if (elapsedDays >= 36 && elapsedDays <= 42) { prRelVsPORel.data.ThirtySix_FourtyTwo++; } else if (elapsedDays >= 43 && elapsedDays <= 49) { prRelVsPORel.data.FourtyThree_FourtyNine++; } else if (elapsedDays >= 50) { prRelVsPORel.data.greaterThanEqualFifty++; } } try { prRelVsPORel.data.Average = Math.Round(totalDays / prRelVsPORel.data.Total, 2); } catch (DivideByZeroException) { prRelVsPORel.data.Average = 0; } totalDays = 0; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // PO Creation vs Confirmation Entry // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// poCreateVsConfEntry.data.Total = Overall.prsOnPOsDt.Rows.Count; foreach (DataRow dr in Overall.prsOnPOsDt.Rows) { string[] strFirstConfCreationDt = (dr["1st Conf Creation Da"].ToString()).Split('/'); int poLineFirstConfYear = int.Parse(strFirstConfCreationDt[2]); int poLineFirstConfMonth = int.Parse(strFirstConfCreationDt[0]); int poLineFirstConfDay = int.Parse(strFirstConfCreationDt[1]); if (poLineFirstConfYear == 0 && poLineFirstConfMonth == 0 && poLineFirstConfDay == 0) { totalUnconf++; continue; } else { poLineFirstConfYear = int.Parse(strFirstConfCreationDt[2]); poLineFirstConfMonth = int.Parse(strFirstConfCreationDt[0]); poLineFirstConfDay = int.Parse(strFirstConfCreationDt[1]); } DateTime initialConfCreateDate = new DateTime(poLineFirstConfYear, poLineFirstConfMonth, poLineFirstConfDay); string[] strPOLineCreateDt = (dr["PO Line Creat#DT"].ToString()).Split('/'); int poLineCreateYear = int.Parse(strPOLineCreateDt[2]); int poLineCreateMonth = int.Parse(strPOLineCreateDt[0].TrimStart('0')); int poLineCreateDay = int.Parse(strPOLineCreateDt[1].TrimStart('0')); DateTime poLineItemCreateDate = new DateTime(poLineCreateYear, poLineCreateMonth, poLineCreateDay); double elapsedDays = (initialConfCreateDate - poLineItemCreateDate).TotalDays; totalDays += elapsedDays; elapsedDays = (int)elapsedDays; if (elapsedDays <= 0) { poCreateVsConfEntry.data.LessThanZero++; } else if (elapsedDays >= 1 && elapsedDays <= 3) { poCreateVsConfEntry.data.One_Three++; } else if (elapsedDays >= 4 && elapsedDays <= 7) { poCreateVsConfEntry.data.Four_Seven++; } else if (elapsedDays >= 8 && elapsedDays <= 14) { poCreateVsConfEntry.data.Eight_Fourteen++; } else if (elapsedDays >= 15 && elapsedDays <= 21) { poCreateVsConfEntry.data.Fifteen_TwentyOne++; } else if (elapsedDays >= 22 && elapsedDays <= 28) { poCreateVsConfEntry.data.TwentyTwo_TwentyEight++; } else if (elapsedDays >= 29 && elapsedDays <= 35) { poCreateVsConfEntry.data.TwentyNine_ThirtyFive++; } else if (elapsedDays >= 36 && elapsedDays <= 42) { poCreateVsConfEntry.data.ThirtySix_FourtyTwo++; } else if (elapsedDays >= 43 && elapsedDays <= 49) { poCreateVsConfEntry.data.FourtyThree_FourtyNine++; } else if (elapsedDays >= 50) { poCreateVsConfEntry.data.greaterThanEqualFifty++; } } try { poCreateVsConfEntry.data.Average = Math.Round(totalDays / poCreateVsConfEntry.data.Total, 2); } catch (DivideByZeroException) { poCreateVsConfEntry.data.Average = 0; } try { poCreateVsConfEntry.data.PercentUnconf = (int)((totalUnconf / poCreateVsConfEntry.data.Total) * 100); } catch (DivideByZeroException) { poCreateVsConfEntry.data.PercentUnconf = 0; } totalDays = 0; PRPO_DB_Utils.CompletedDataLoads++; MethodInvoker del = delegate { PRPO_DB_Utils.UpdateDataLoadProgress(); }; del.Invoke(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, "KPI -> Purch Sub Calculation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void StatusBar(string UpdateText, int section = 1, string Timer = "", string JobName = "") //update statusbar text { if (mainStatusBar == null) { return; } // statusbar wasn't initiated in project startup // updates status bar text (from any thread) if (section == 2) { sbStopWatchJobName = JobName; } // store job name in sb while executing with timer if (Timer.ToUpper() == "START") { statusBarTimerThread("Start"); } if (Timer.ToUpper() == "STOP") { statusBarTimerThread("Stop"); } if (section == 1) { try { MethodInvoker inv = delegate { if (SBGui.thisStatusPanel != null) { SBGui.thisStatusPanel.Text = UpdateText; } }; SBGui.thisForm.Invoke(inv); } catch { if (SBGui.thisStatusPanel != null) { SBGui.thisStatusPanel.Text = UpdateText; } } } if (section == 2) { try { MethodInvoker inv = delegate { if (SBGui.thisDatePanel != null) { SBGui.thisDatePanel.Text = UpdateText; } }; { }; SBGui.thisForm.Invoke(inv); } catch { if (SBGui.thisDatePanel != null) { SBGui.thisDatePanel.Text = UpdateText; } } } }
private void ReceiveVideoAsync(object arg) { var client = (TcpClient)arg; var stream = client.GetStream(); try { Interlocked.Exchange(ref running, 1); MethodInvoker uiConnected = () => { groupBox_Settings.Enabled = false; button_Connect.Text = disconnectStr; toolStripStatusLabel_Status.Text = connectedStr; }; this.Invoke(uiConnected); using (var reader = new BinaryReader(stream, System.Text.Encoding.ASCII, true)) { using (var writer = new BinaryWriter(stream, System.Text.Encoding.ASCII, true)) { var img = new Mat(); int fps = 0, lastFps = 0, lastWidth = 0, lastHeight = 0; MethodInvoker invoker = () => { var tmp = frameBox.Image; frameBox.Image = BitmapConverter.ToBitmap(img); //frameBox.Refresh(); if (img.Width != lastWidth) { toolStripStatusLabel_Width.Text = img.Width.ToString(); lastWidth = img.Width; } if (img.Height != lastHeight) { toolStripStatusLabel_Height.Text = img.Height.ToString(); lastHeight = img.Height; } if (fps != lastFps) { toolStripStatusLabel_Fps.Text = fps.ToString(); lastFps = fps; } tmp?.Dispose(); }; int fpsCounter = 0; Stopwatch sw = Stopwatch.StartNew(); try { while (Interlocked.Read(ref cancelled) == 0 && client.Connected && stream.CanRead) { writer.Write((byte)command); int size = reader.ReadInt32(); if (size < 0) { throw new ApplicationException(size.ToString()); } { byte[] imgBuffer = stream.ReadAll(size); img = Cv2.ImDecode(imgBuffer, ImreadModes.Color); if (img.Size() != OpenCvSharp.Size.Zero) { frameBox.Invoke(invoker); //Execute in UI thread fpsCounter++; } if (sw.ElapsedMilliseconds >= 1000) { sw.Restart(); fps = fpsCounter; fpsCounter = 0; } } GC.Collect(0, GCCollectionMode.Forced, false, true); } } finally { sw.Stop(); } } } } catch (EndOfStreamException ex) { this.Invoke((MethodInvoker)(() => MessageBox.Show(this, ex.ToString(), "Stream Error", MessageBoxButtons.OK, MessageBoxIcon.Error))); } catch (IOException ex) { this.Invoke((MethodInvoker)(() => MessageBox.Show(this, ex.ToString(), "Stream Error", MessageBoxButtons.OK, MessageBoxIcon.Error))); } finally { Interlocked.Exchange(ref running, 0); stream.Close(); client.Close(); MethodInvoker uiDisconnected = () => { groupBox_Settings.Enabled = true; button_Connect.Text = connectStr; toolStripStatusLabel_Status.Text = disconnectedStr; }; this.Invoke(uiDisconnected); GC.Collect(); } }
public static Thread StartTry(MethodInvoker code, ErrorHandler on_error = null, MethodInvoker on_finally = null, bool background = true) { Thread t = new Thread( () => { try { code.Invoke(); } catch (ThreadAbortException) { } catch (Exception e) { if (on_error != null) { on_error.Invoke(e); } else { Message.Error(e); } } finally { on_finally?.Invoke(); } } ); t.IsBackground = background; t.Start(); return(t); }
// void bw_DoWork(object sender, DoWorkEventArgs e) void bw_DoWork(System.IO.Ports.SerialPort sport) { // 需要在此写入接收程序,判断信息 // System.IO.Ports.SerialPort sport = e.Argument as System.IO.Ports.SerialPort; string sp = sport.PortName; string stationName = GetEquipNo(sp); string StationNo = GetStationNo(sp); bool equiptype = IfOld(sp); if (equiptype == false) { byte[] RcvBytes = new byte[sport.BytesToRead]; Thread.Sleep(3000); int lIntLen = sport.Read(RcvBytes, 0, RcvBytes.Length); if (params1 != null) { params1 = null; } //从串口获取数据 params1 = new ObsParams(); // 定义到数据库文件,应该是一样的 if (lIntLen < 25) { byte[] RcyByte_all = RcvBytes; sp = sport.PortName; stationName = GetEquipNo(sp); StationNo = GetStationNo(sp); byte[] RcvBytes_new = new byte[sport.BytesToRead]; lIntLen = sport.Read(RcvBytes_new, 0, RcvBytes_new.Length); byte[] result = new byte[RcyByte_all.Length + RcvBytes_new.Length]; RcyByte_all.CopyTo(result, 0); RcvBytes_new.CopyTo(result, RcyByte_all.Length); RcvBytes = result; //lIntLen = sport.Read(RcvBytes, 0, RcvBytes.Length); if (RcvBytes.Length < 25) { return; } } params1 = Common.GetObsParams(RcvBytes); } else { char[] RcvBytes_old = new char[sport.BytesToRead]; Thread.Sleep(3000); int lIntLen = sport.Read(RcvBytes_old, 0, RcvBytes_old.Length); if (params1 != null) { params1 = null; } //从串口获取数据 params1 = new ObsParams(); // 定义到数据库文件,应该是一样的 if (lIntLen < 117) { char[] RcyByte_all = RcvBytes_old; sp = sport.PortName; stationName = GetEquipNo(sp); StationNo = GetStationNo(sp); char[] RcvBytes_new =new char[sport.BytesToRead]; lIntLen = sport.Read(RcvBytes_new, 0, RcvBytes_new.Length); char[] result = new char[RcyByte_all.Length + RcvBytes_new.Length]; RcyByte_all.CopyTo(result, 0); RcvBytes_new.CopyTo(result, RcyByte_all.Length); RcvBytes_old = result; } string RcvBytes_string = new string(RcvBytes_old); params1 = Common.GetObsParams_old(RcvBytes_string); //lIntLen = sport.Read(RcvBytes, 0, RcvBytes.Length); if (RcvBytes_old.Length < 117) { return; } } if (params1 == null) { return; } params1.StationName = stationName; int.TryParse(StationNo, out params1.StationNO); // int ret = DAO.Exist(params1.StationName, params1.ObsTime);// 判断是否有重复的数据 //if (ret<1) //{ DAO.InsertData(params1); try { ObsParams parameter_lg =new ObsParams(); ObsParams parameter_yp = new ObsParams(); ObsParams parameter_gly = new ObsParams(); ObsParams parameter_zhtb = new ObsParams(); ObsParams parameter_wwz = new ObsParams(); ObsParams parameter_swzy = new ObsParams(); ObsParams parameter_jsd = new ObsParams(); ObsParams parameter_hj = new ObsParams(); ObsParams parameter_tc = new ObsParams(); if (params1.StationNO != null) { // Member.obsParamsList.Add(params1); switch (Convert.ToInt32(params1.StationNO)) { case 1: Member.parameter_lg = params1; break; case 2: Member.parameter_yp = params1; break; case 3: Member.parameter_jsd = params1; break; case 4: Member.parameter_zhtb = params1; break; case 5: Member.parameter_tc = params1; break; case 6: Member.parameter_swzy = params1; break; case 7: Member.parameter_hj = params1; break; case 8: Member.parameter_gly = params1; break; case 9: Member.parameter_wwz = params1; break; default: //Member.parameter_wwz = params1; break; } } } catch (System.Exception ex) { } /*case 1 Member.parameter_lg = params1; endswitc if (Convert.ToInt32(params1.StationNO) == 1) { Member.parameter_lg = params1; } if (Convert.ToInt32(params1.StationNO) == 2) { Member.parameter_yp = params1; } if (Convert.ToInt32(params1.StationNO) == 3) { Member.parameter_jsd = params1; } if (Convert.ToInt32(params1.StationNO) == 4) { Member.parameter_zhtb = params1; } if (Convert.ToInt32(params1.StationNO) == 5) { Member.parameter_tc = params1; } if (Convert.ToInt32(params1.StationNO) == 6) { Member.parameter_swzy = params1; } if (Convert.ToInt32(params1.StationNO) == 7) { Member.parameter_hj = params1; } if (Convert.ToInt32(params1.StationNO) == 8) { Member.parameter_gly = params1; } if (Convert.ToInt32(params1.StationNO) == 9) { Member.parameter_wwz = params1; }*/ //frmobsdatall.FenpeiData(params1); // 判断是否大于1000,数据是否增加 biyonghrng xinjia //if (params1.Hour==0 && params1.Minute==0) //{ // GHISum1000 = new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // GTISum1000 = new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //} //else //{ // if (params1.GHI >= 1000 || params1.GTI >= 1000) // { // GHISum1000[params1.StationNO-1] = GHISum1000[params1.StationNO-1] + params1.GHI / 1000000*20; // GTISum1000[params1.StationNO-1] = GTISum1000[params1.StationNO-1] + params1.GTI / 1000000*20; // DAO.InsertData1000(params1,GHISum1000,GTISum1000); // } //} ////// //MysqlConnection.InsertToDb(params1); //InsertFirstDataDao.readHistoryData(); //Ms_SQLDAO.InsertToDb(params1); //} if (stationName == selectStationNo) { MethodInvoker mi = new MethodInvoker(SetControlsProp); BeginInvoke(mi); } }
protected void RunOnWorker(MethodInvoker method) { RunOnWorker(method, false); }
/// <summary> /// easy method to handle cross-thread calls on a windows form. /// </summary> /// <param name="task"></param> public void EasyInvoke(MethodInvoker task) { if (this.InvokeRequired) this.Invoke(task); else task.Invoke(); }