title: Sending a notification popup in winforms from another thread
body: <p>I've run into a unique little error in my basic chat program which states that I cannot send a <a href="https://github.com/Tulpep/Notification-Popup-Window" rel="nofollow">Notification Popup</a> from another thread:</p>
  
  <pre><code>An exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll but was not handled in user code
  
  Additional information: Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
  </code></pre>
  
  <p>This occurs when I call <code>popupNotification.Popup();</code> from this method:</p>
  
  <pre><code>void ChatServer_OnDataReceived(object sender, ReceivedArguments e)
      {
          string machine = e.Name;
          string message = e.ReceivedData;
          popupNotification.TitleText = "New  message";
          popupNotification.ContentText = machine + " sent a message at " + DateTime.Now.ToShortTimeString() +
              ", saying  \"" + message + "\"";
          popupNotification.Popup();
          changeTextBoxContents(e.Name + " sent a message at " + DateTime.Now.ToShortTimeString() +
              ", saying  \"" + e.ReceivedData + "\"");
      }
  </code></pre>
  
  <p>I'm trying to create the cross-thread code which should look like this:</p>
  
  <pre><code>public delegate void UpdatePopup(PopupNotifier notificationPopup);
  
  void sendAPopup(PopupNotifier notificationPopup)
      {
          if (notificationPopup.InvokeRequired)
          {
              Invoke(new UpdatePopup(sendAPopup), new object[] { notificationPopup });
          }
          else
          {
              notificationPopup.Popup();
          }
      }
  </code></pre>
  
  <p>However, the notification popup window library doesn't have a Invoke Required method, so I'm out of luck on that fix.</p>
  
  <p>Can anyone help?</p>