title: C# How to create a Singleton that publishes events & Classes that subscribe?
body: <p><strong>Goal:</strong> Have a singleton publish events and allow any class to subscribe/listen to those events</p>
  
  <p><strong>Problem:</strong> I cannot figure out how to do this. The code below is illegal but it purveys what I'm trying to do</p>
  
  <p><strong>TransmitManager Class - Publisher</strong></p>
  
  <pre><code>    //Singleton
      public sealed class TransmitManager
      {
  
          delegate void TransmitManagerEventHandler(object sender);
          public static event TransmitManagerEventHandler OnTrafficSendingActive;
          public static event TransmitManagerEventHandler OnTrafficSendingInactive;
  
          private static TransmitManager instance = new TransmitManager();
  
  
  
          //Singleton
          private TransmitManager()
          {
  
          }
  
          public static TransmitManager getInstance()
          {
              return instance;
          }
  
          public void Send()
          {
             //Invoke Event
             if (OnTrafficSendingActive != null)
                OnTrafficSendingActive(this);
  
            //Code connects &amp; sends data
  
            //Invoke idle event
            if (OnTrafficSendingInactive != null)
              OnTrafficSendingInactive(this);
  
         }
     }
  </code></pre>
  
  <p><strong>Test Class - Event Subscriber</strong></p>
  
  <pre><code>   public class Test
     {
  
       TrasnmitManager tm = TransmitManager.getInstance();
  
       public Test()
       {
          //I can't do this below. What should my access level be to able to do this??
  
          tm.OnTrafficSendingActive += new TransmitManagerEventHandler(sendActiveMethod);
  
       }
  
       public void sendActiveMethod(object sender)
       {
  
          //do stuff to notify Test class a "send" event happend
       }
    }
  </code></pre>