Ejemplo n.º 1
0
 private void SetMessage(TextBox txtIn, string MyMessageIn)
 {
     try
     {
         if (!MyMessageIn.EndsWith(Environment.NewLine))
         {
             MyMessageIn += Environment.NewLine;//加上换行符
         }
         if (this.InvokeRequired)
         {
             SetMessageCallBack tmpMessage = new SetMessageCallBack(SetMessage);
             this.Invoke(tmpMessage, new object[] { txtIn, MyMessageIn });
         }
         else
         {
             txtIn.Text = MyMessageIn;
         }
     }
     catch (Exception ex)
     {
         //线程时间太短,容易在关闭窗口时引起异常:
         //无法访问已释放的对象。对象名:“Form1”。
         string tmp = ex.Message;
     }
 }
Ejemplo n.º 2
0
 private void Message(string message)
 {
     try
     {
         if (ProgressBar1.InvokeRequired)
         {
             SetMessageCallBack c = Message;
             Invoke(c, message);
         }
         else
         {
             string[] lines = TxtInfo.Lines;
             if (lines.Length > 0)
             {
                 lines[1]      = "Device status: Bootloader mode " + message;
                 TxtInfo.Lines = lines;
             }
         }
     }
     catch
     {
     }
 }