private void SetTrackBar() { if (this.trackBar1.InvokeRequired) { SetTrackbarCallBack d = new SetTrackbarCallBack(SetTrackBar); this.Invoke(d, new object[] { }); } else { this.trackBar1.Maximum = connectionList.Count; SetLabelText(label1, "#" + this.trackBar1.Value); } }
/// <param name="message"></param> /// <summary> /// Update TrackBar /// </summary> /// <param name="message"></param> private void trackBarUpdate(TrackBar trackBar, int value) { if (trackBar.InvokeRequired) ///InvokeRequired required compares the thread ID of the calling thread to the thread ID of the creating thread. If these threads are different, it returns true. { SetTrackbarCallBack d = new SetTrackbarCallBack(trackBarUpdate); Invoke(d, new object[] { trackBar, value }); } else { trackBar.Value = value; } }