title: CoreScanner (Motorola) Events not being triggered C#
body: <p>I am attempting to a simple windows form application, where the users scans a barcode then the application decodes the barcode, then inserts an row into a database. A basic track application. I picked up a Motorola scanner and downloaded the SDK for windows development. I read though "APPENDIX A WRITE SIMPLE APPLICATIONS USING THE SCANNER SDK API" seemed like a good place to start in the Developers guide (<a href="http://support.symbol.com/support/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=14978402apdf&amp;sliceId=&amp;dialogID=311240750&amp;stateId=1%200%20311224446" rel="nofollow noreferrer">http://support.symbol.com/support/search.do?cmd=displayKC&amp;docType=kc&amp;externalId=14978402apdf&amp;sliceId=&amp;dialogID=311240750&amp;stateId=1%200%20311224446</a>). I get the 5 console examples working fine but I can't get the windows form application to work, the OnBarcode Event is never triggered. I followed this video(<a href="http://www.youtube.com/watch?v=GfIWWUw4YSc&amp;t=15m47s" rel="nofollow noreferrer">http://www.youtube.com/watch?v=GfIWWUw4YSc&amp;t=15m47s</a>) by Motorola step by step.  </p>
  
  <p>I seem to be having a similar problem to this: <a href="https://stackoverflow.com/questions/8807297/motorola-barcode-scanner-sdk-events-c-sharp">Motorola barcode scanner SDK events C#</a> but I am using a USB connection.</p>
  
  <p>I realized that the sample code was original written in .net 2.0 so I tried recompiling the project and it still didn't' work. I then tried changing CCoreScannerClass to CCoreScanner so that Embeded Interop Types would work but that didn't help either. Here is the sample code:</p>
  
  <pre><code>using CoreScanner;
  
  namespace Scanner_WindowsFormsApplication
  {
  public partial class Form1 : Form
  {
      CCoreScanner cCoreScanner;
      public Form1()
      {
          InitializeComponent();
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
  
      }
      void OnBarcodeEvent(short eventType, ref string pscanData)
      {
          string barcode = pscanData;
          this.Invoke((MethodInvoker)delegate { textBox1.Text = barcode; });
  
  
      }
      private void button1_Click(object sender, EventArgs e)
      {
          try
          {
              //Instantiate CoreScanner Class
              cCoreScanner = new CCoreScanner();
              //Call Open API
              short[] scannerTypes = new short[1];//Scanner Types you are interested in
              scannerTypes[0] = 1; // 1 for all scanner types
              short numberOfScannerTypes = 1; // Size of the scannerTypes array
              int status; // Extended API return code
              cCoreScanner.Open(0, scannerTypes, numberOfScannerTypes, out status);
              // Subscribe for barcode events in cCoreScannerClass
              cCoreScanner.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
              // Let's subscribe for events
              int opcode = 1001; // Method for Subscribe events
              string outXML; // XML Output
              string inXML = "&lt;inArgs&gt;" +
              "&lt;cmdArgs&gt;" +
              "&lt;arg-int&gt;1&lt;/arg-int&gt;" + // Number of events you want to subscribe
              "&lt;arg-int&gt;1&lt;/arg-int&gt;" + // Comma separated event IDs
              "&lt;/cmdArgs&gt;" +
              "&lt;/inArgs&gt;";
              cCoreScanner.ExecCommand(opcode, ref inXML, out outXML, out status);
              Console.WriteLine(outXML);
          }
          catch (Exception exp)
          {
              Console.WriteLine("Something wrong please check... " + exp.Message);
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I read through the Developer guide and found this: "BarcodeEvent
  Triggered when a scanner captures bar codes. To receive BarcodeEvents, an application needs to execute the REGISTER_FOR_EVENTS method with the SUBSCRIBE_BARCODE event type." I am new to c# so I don't really know what this means and how it applies to the example.</p>
  
  <p>If <a href="https://stackoverflow.com/users/68043/scott">https://stackoverflow.com/users/68043/scott</a> reads this thread I would love to know how you got the onBarcodeEvent to function in your thread: <a href="https://stackoverflow.com/questions/9799900/dialog-hangs-when-called-from-event">Dialog hangs when called from event</a></p>