/*
        /// <summary>
        /// Log to the output...
        /// This method demonstrates a pattern for making thread-safe
        /// calls on a Windows Forms control. 
        /// 
        /// If the calling thread is different from the thread that
        /// created the TextBox control, this method creates a
        /// SetTextCallback and calls itself asynchronously using the
        /// Invoke method.
        ///
        /// If the calling thread is the same as the thread that created
        /// the TextBox control, the Text property is set directly. 
        /// </summary>
        /// <param name="Message"></param>
        public void Log(String Message)
        {
            // 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.listBoxResults.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(Log);
                this.Invoke(d, new object[] { Message });
            }
            else
            {
                this.listBoxResults.Items.Add(Message);
            }
        }

        public void LogColored(String Message)
        {
            // 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.listBoxResults.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(Log);
                this.Invoke(d, new object[] { Message });
            }
            else
            {
                // mmb - this doesn't work!  Colors all text to red, and then black again, not just the 1 line
                this.listBoxResults.ForeColor = Color.Red;
                this.listBoxResults.Items.Add(Message);
                this.listBoxResults.ForeColor = Color.Black;
            }
        }
*/
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Message"></param>
        public void AddToResults(String[] Message)
        {
            // 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.dataGridViewResults.InvokeRequired)
            {
                SetResultsCallback d = new SetResultsCallback(AddToResults);
                this.Invoke(d, new object[] { Message });
            }
            else
            {
                this.dataGridViewResults.Rows.Add(Message);
            }
        }
Exemplo n.º 2
0
/*
 *      /// <summary>
 *      /// Log to the output...
 *      /// This method demonstrates a pattern for making thread-safe
 *      /// calls on a Windows Forms control.
 *      ///
 *      /// If the calling thread is different from the thread that
 *      /// created the TextBox control, this method creates a
 *      /// SetTextCallback and calls itself asynchronously using the
 *      /// Invoke method.
 *      ///
 *      /// If the calling thread is the same as the thread that created
 *      /// the TextBox control, the Text property is set directly.
 *      /// </summary>
 *      /// <param name="Message"></param>
 *      public void Log(String Message)
 *      {
 *          // 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.listBoxResults.InvokeRequired)
 *          {
 *              SetTextCallback d = new SetTextCallback(Log);
 *              this.Invoke(d, new object[] { Message });
 *          }
 *          else
 *          {
 *              this.listBoxResults.Items.Add(Message);
 *          }
 *      }
 *
 *      public void LogColored(String Message)
 *      {
 *          // 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.listBoxResults.InvokeRequired)
 *          {
 *              SetTextCallback d = new SetTextCallback(Log);
 *              this.Invoke(d, new object[] { Message });
 *          }
 *          else
 *          {
 *              // mmb - this doesn't work!  Colors all text to red, and then black again, not just the 1 line
 *              this.listBoxResults.ForeColor = Color.Red;
 *              this.listBoxResults.Items.Add(Message);
 *              this.listBoxResults.ForeColor = Color.Black;
 *          }
 *      }
 */
        /// <summary>
        ///
        /// </summary>
        /// <param name="Message"></param>
        public void AddToResults(String[] Message)
        {
            // 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.dataGridViewResults.InvokeRequired)
            {
                SetResultsCallback d = new SetResultsCallback(AddToResults);
                this.Invoke(d, new object[] { Message });
            }
            else
            {
                this.dataGridViewResults.Rows.Add(Message);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Message"></param>
 public void AddToResults(String Message)
 {
     // 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.listBoxResults.InvokeRequired)
     {
         SetResultsCallback d = new SetResultsCallback(AddToResults);
         this.Invoke(d, new object[] { Message });
     }
     else
     {
         this.listBoxResults.Items.Add(Message);
         this.listBoxResults.SelectedIndex = this.listBoxResults.Items.Count - 1;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Message"></param>
 public void AddToResults(String Message)
 {
     // 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.listBoxResults.InvokeRequired)
     {
         SetResultsCallback d = new SetResultsCallback(AddToResults);
         this.Invoke(d, new object[] { Message });
     }
     else
     {
         this.listBoxResults.Items.Add(Message);
         this.listBoxResults.SelectedIndex = this.listBoxResults.Items.Count - 1;
     }
 }