-2

I have been given a project in which I have to use activeX control without form.

That activex control belong to a Card swiper device. So what I have to do is, to create a rest service by which any browser client can access card's swiped data.

So I created a webservice method which creates a new sta thread as soon as request comes. In this sta thread I create ActiveXcontrol like given below and stores data in static class. Again for the second request I do the same.

try
{
    axOPOSMSR1 = new AxOposMSR_CCO.AxOPOSMSR();
    axOPOSMSR1.CreateControl();
    if (axOPOSMSR1.Open("IDTECH_SECUREMAG_USBHID") == 0)
    {
        axOPOSMSR1.ClaimDevice(100);
        axOPOSMSR1.DeviceEnabled = true;
        axOPOSMSR1.DataEventEnabled = true;
        axOPOSMSR1.DecodeData=true;
        axOPOSMSR1.ParseDecodeData = true;

        while (!Devicedisable && (axOPOSMSR1.Track1Data == ""))
        {
        }

        axOPOSMSR1.ClearInput();
        axOPOSMSR1.ReleaseDevice();
        axOPOSMSR1.Close();
        axOPOSMSR1.Dispose();
        axOPOSMSR1.ContainingControl = null;
        axOPOSMSR1 = null;
        GC.Collect();
    }

For the first time this program is doing well but as soon as I make another request (make another thread) nothing get stored in (static class) as data.

I make second request after first has been served.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Satish2230
  • 13
  • 6

1 Answers1

1

What i have understand about your problem is:

  • You created a object of Swiper class with a new thread.
  • Now you are accessing Chipper data using a WCF service.

I don't have such hardware device but would you please put

Thread.sleep(10000); 

after the while condition and tell me the output.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Amit Pal
  • 10,604
  • 26
  • 80
  • 160