private void ShowMessage(string content, string caption)
 {
         ShowMessageCallback d = new ShowMessageCallback(ShowMessageMethod);
         this.Invoke(d, new object[] { content,caption });
 }
Пример #2
0
        //void m_ftp_Connected(FTP source)
        //{
        //    AppendMessage("Connected");
        //}

        //void m_ftp_ResponseReceived(FTP source, FTPResponse Response)
        //{
        //    AppendMessage(Response.Text);
        //}

        private void ShowMessage(string newMessage, int mode)
        {
            if (this.InvokeRequired)
            {
                ShowMessageCallback d = new ShowMessageCallback(ShowMessage);
                this.Invoke(d, new object[] { newMessage, mode });
            }
            else
            {
                if (mode == 1)
                {
                    if ("".Equals(newMessage) || newMessage == null)
                    {
                        newMessage = "Problem Occured, please try again.";
                    }
                    MessageBox.Show(newMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand,
                                    MessageBoxDefaultButton.Button1);
                }
                else
                {
                    TimeSpan usedTime = (startTest - endTest).Duration();
                    string   hours    = usedTime.Hours.ToString().PadLeft(2, '0');
                    string   minutes  = usedTime.Minutes.ToString().PadLeft(2, '0');
                    string   seconds  = usedTime.Seconds.ToString().PadLeft(2, '0');
                    string   hms      = hours + ":" + minutes + ":" + seconds;
                    MessageBox.Show("Send Data Successful" + "\r\n" + "Used Time : " + hms, "Success",
                                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
            }
        }
Пример #3
0
        void Receive()
        {
            try
            {
                while (true)
                {
                    if (stopReceive == true)
                    {
                        break;
                    }
                    IPEndPoint ipendpoint = null;
                    byte[]     message    = udpChat.Receive(ref ipendpoint);

                    if (messageBOX.InvokeRequired)
                    {
                        ShowMessageCallback dt = new ShowMessageCallback(ShowMessage);
                        Invoke(dt, new object[] { Encoding.Default.GetString(message) });
                    }
                    else
                    {
                        ShowMessage(Encoding.Default.GetString(message));
                    }
                }
            }


            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
			private delegate void ShowErrorCallback(Form frmWindow, string strMessage, Exception objException); // Permite llamadas asíncronas para mostrar un mensaje
			
		/// <summary>
		///		Muestra un cuadro de mensaje
		/// </summary>
		public static void ShowMessage(Form frmWindow, string strMessage)
		{ // InvokeRequired compara el ID del hilo llamante con el ID del hilo creador, si son diferentes devuelve True
				if (frmWindow != null && frmWindow.InvokeRequired)
					{	ShowMessageCallback fncCallback = new ShowMessageCallback(ShowMessage);
					
							frmWindow.Invoke(fncCallback, new object[] { frmWindow, strMessage });
					}
				else
					MessageBox.Show(frmWindow, strMessage, Application.ProductName);
		}
Пример #5
0
 public void ShowMessage(string message)
 {
     if (rtbMessage.InvokeRequired)
     {
         ShowMessageCallback d = new ShowMessageCallback(ShowMessage);
         this.Invoke(d, new object[] { message });
     }
     else
     {
         rtbMessage.AppendText(message + "\n");
     }
 }
Пример #6
0
 public void ShowMessage(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
 {
     if (this.InvokeRequired)
     {
         ShowMessageCallback callback = new ShowMessageCallback(ShowMessage);
         this.Invoke(callback, new object[] {message, caption, buttons, icon});
     }
     else
     {
         MessageBox.Show(message, caption, buttons, icon);
     }
 }
Пример #7
0
 void ShowMessage(string message)
 {
     if (textBox3.InvokeRequired)
     {
         ShowMessageCallback dt = new ShowMessageCallback(ShowMessage);
         Invoke(dt, new object[] { message });
     }
     else
     {
         textBox3.Text = message;
     }
 }
Пример #8
0
        private delegate void ShowErrorCallback(Form frmWindow, string strMessage, Exception objException); // Permite llamadas asíncronas para mostrar un mensaje

        /// <summary>
        ///		Muestra un cuadro de mensaje
        /// </summary>
        public static void ShowMessage(Form frmWindow, string strMessage)
        {         // InvokeRequired compara el ID del hilo llamante con el ID del hilo creador, si son diferentes devuelve True
            if (frmWindow != null && frmWindow.InvokeRequired)
            {
                ShowMessageCallback fncCallback = new ShowMessageCallback(ShowMessage);

                frmWindow.Invoke(fncCallback, new object[] { frmWindow, strMessage });
            }
            else
            {
                MessageBox.Show(frmWindow, strMessage, Application.ProductName);
            }
        }
Пример #9
0
        public void ShowMessage(String msg, Image image)
        {
            // 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.

            // 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 (Form.CheckForIllegalCrossThreadCalls && this.StatusLabel.GetCurrentParent() != null && this.StatusLabel.GetCurrentParent().Parent.InvokeRequired)
            {
                ShowMessageCallback d = new ShowMessageCallback(ShowMessage);
                this.Invoke(d, new object[] { msg, image });

                //SetImageCallback d = new SetImageCallback(image);
                //this.Invoke(d, new object[] { image });
            }
            else
            {
                this.StatusLabel.Text  = msg;
                this.StatusLabel.Image = image;
            }
        }
        public void ShowMessage(String msg, Image image)
        {
            // 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.

            // 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 (Form.CheckForIllegalCrossThreadCalls && this.StatusLabel.GetCurrentParent()!=null && this.StatusLabel.GetCurrentParent().Parent.InvokeRequired)
            {
                ShowMessageCallback d = new ShowMessageCallback(ShowMessage);
                this.Invoke(d, new object[] { msg ,image});

                //SetImageCallback d = new SetImageCallback(image);
                //this.Invoke(d, new object[] { image });
            }
            else
            {
                this.StatusLabel.Text = msg;
                this.StatusLabel.Image = image;
            }
        }
Пример #11
0
 void ShowMessage(string message)
 {
     if (textBoxReceive.InvokeRequired)
     {
         ShowMessageCallback dt = new ShowMessageCallback(ShowMessage);
         Invoke(dt, new object[] { message });
     }
     else
     {
         textBoxReceive.Text = message;
     }
 }