title: How can I listen to this event on a different thread?
body: <p>I've made a little test program to try and get a USB card reader working using an ActiveX control provided by the manufacturer.</p>
  
  <p>The form works fine as long as it doesn't use a separate thread. I create a new instance of <code>Reader</code> and listen to the <code>Read</code> event and everything works fine. I swipe a card, the event fires and the textbox gets updated.</p>
  
  <pre><code>private Reader _reader;
  
  public Form1()
  {
      InitializeComponent();
      CreateScanner();
  }
  
  public void CreateScanner()
  {
      _reader = new Reader();
      _reader.Read += Read;
  }
  
  void Read(object sender, EventArgs e)
  {
      CardData.Text = "Card Read";
  }
  </code></pre>
  
  <p>Reader class in case it helps:</p>
  
  <pre><code>public class Reader
  {
      private AxUSBHIDInsert _axUsbHid;
      public event EventHandler Read;
  
      public Reader()
      {
          _axUsbHid = new AxUSBHIDInsert();
          _axUsbHid.CreateControl();
          _axUsbHid.BeginInit();
          _axUsbHid.MSRReadDir = MSRReadDirection.ReadWithdrawal;
          _axUsbHid.EndInit();
  
          _axUsbHid.PortOpen = true;
  
          _axUsbHid.CardDataChanged += CardDataChanged;
      }
  
      void CardDataChanged(object sender, EventArgs e)
      {
          if (Read != null)
              Read(this, new EventArgs());
      }
  }
  </code></pre>
  
  <p>However, I need to run this on a separate thread. So I change the constructor to be</p>
  
  <pre><code>Thread thread = new Thread(CreateScanner);
  thread.SetApartmentState(ApartmentState.STA);
  thread.Start();
  </code></pre>
  
  <p>It has to be an STA thread otherwise the ActiveX control will complain that it cannot be instantiated. However doing this, the event doesn't fire anymore. I'm not that familiar with how threading works, so I'm not sure why.</p>
  
  <p>Any ideas? Note that it has to work this way (separate thread, hooked up to the Read event), because the code will eventually reside in a class library that gets deployed with an application that I cannot change.</p>