Beispiel #1
0
        //Control - Invoke

        private void SetListBox(String sInput)
        {
            // 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.
            if (this.lbController.InvokeRequired)
            {
                SetItemsCallback d = new SetItemsCallback(SetListBox);
                this.Invoke(d, new object[] { sInput });
            }
            else
            {
                this.lbController.Items.Add(sInput);
                this.lbController.SelectedIndex = this.lbController.Items.Count - 1;
            }
        }
 //Control - Invoke
 private void SetListBox(String sInput)
 {
     // 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.
     if (this.lbController.InvokeRequired)
     {
         SetItemsCallback d = new SetItemsCallback(SetListBox);
         this.Invoke(d, new object[] { sInput });
     }
     else
     {
         this.lbController.Items.Add(sInput);
         this.lbController.SelectedIndex = this.lbController.Items.Count - 1;
     }
 }