//This is the decleration at the begining of the main thread used by timers and new thread //delegate so worker threads can call local functions public delegate void DoSomething(); // this is part of the new thread code where the delegate is being called if (this.InvokeRequired) { try { DoSomething d = new DoSomething(LoadChange); this.Invoke(d); } catch (ObjectDisposedException r) { MessageBox.Show("caught Object Dispose {0}", r.ToString()); } catch (NullReferenceException r) { MessageBox.Show("caught null ref {0}", r.ToString()); } catch (IndexOutOfRangeException r) { MessageBox.Show("caught ind out of range {0}", r.ToString()); } } else this.LoadChange(); Thread.Sleep(frq); } } catch (Exception ex) { MessageBox.Show("Error in repeat send routine." + ex); } START.BackColor = Color.LightSkyBlue; } //this is function in the main thread to be called by the delegate private void LoadChange() { string current = repeat; if (!current.Equals(repeat)) { Message2.Text += repeat; current = repeat; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)