Ejemplo n.º 1
0
 private void SetVisibility(Control c, bool visible)
 {
     if (c.InvokeRequired)
     {
         SetVisibilityCallback cb = new SetVisibilityCallback(SetVisibility);
         this.Invoke(cb, new object[] { c, visible });
     }
     else
     {
         c.Visible = visible;
     }
 }
 private void SetVisibility(Control c, bool visible)
 {
     if (c.InvokeRequired)
     {
         SetVisibilityCallback cb = new SetVisibilityCallback(SetVisibility);
         this.Invoke(cb, new object[] { c, visible });
     }
     else
     {
         c.Visible = visible;
     }
 }
Ejemplo n.º 3
0
 public void SetVisibility(bool check)
 {
     //Thread Safe
     if (this.InvokeRequired)
     {
         SetVisibilityCallback d = new SetVisibilityCallback(SetVisibility);
         this.Invoke(d, new object[] { check });
     }
     else
     {
         butConnect.Enabled    = check;
         butDisconnect.Enabled = !check;
         txtNick.Enabled       = check;
         txtIp.Enabled         = check;
         txtPort.Enabled       = check;
         if (check)
         {
             c = null;
         }
     }
 }
Ejemplo n.º 4
0
        //used for setting visibility also out of principal threading
        private void setVisibility(string controlName, bool value)
        {
            Control control = this.Controls.Find(controlName, true).FirstOrDefault();

            try
            {
                if (control.InvokeRequired)
                {
                    SetVisibilityCallback d = new SetVisibilityCallback(setVisibility);
                    this.Invoke(d, new object[] { controlName, value });
                }
                else
                {
                    control.Visible = value;
                }
            }
            catch
            {
                //probably you've close the form before this thread finish.
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the visibility for asynchronous calls in a thread safe manner.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="visible">The visibility is set to <paramref name="visible"/>.</param>
 protected void SetVisibilitySafe(Control control, bool visible)
 {
     // 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 (control.InvokeRequired)
     {
         SetVisibilityCallback d =
             new SetVisibilityCallback(SetVisibilitySafe);
         Invoke(d, new object[] {control, visible});
     }
     else
     {
         control.Visible = visible;
     }
 }