jwize
jwize

Reputation: 4165

How can I keep my state alive while reading from an iris device?

I have a central web application which starts an iris scanning device on the users PC. Our clients install our scanner drivers so that can track people coming and going from their sites.

  1. The user logs into the website and clicks the scan link.
  2. There is a locally installed WebAPI service that fields calls from the website.
  3. The WebAPI service activates a COM component that starts the scanning process.
  4. Once the user has completed the iris scan it returns to an event handler with the result.

Here is where the problem lies. In order for the scan to complete there has to be a live reference to the COM object until it is done. However, once the scan starts the code continues on and returns from the local service call. At that point the context is lost and likely the memory gets marked for cleanup breaking the process.

Is seems like a bad idea to lock the WebAPI service and wait for some response internally potentially locking up and crashing the web app.

How can I architect this to handle the process in a robust manner while avoiding any applications from being locked up?

I was thinking to maybe create a windows service that runs constantly in the background wherein an AppDomain is loaded for each scan request. The requests could process while my web app was polling for state changes via the webservice.

Upvotes: 0

Views: 74

Answers (1)

Abdullah Dibas
Abdullah Dibas

Reputation: 1507

I think you need just to wrap your COM component object in a Singleton class where it's only instantiated once. (Read this for more information about Singleton).

Also if you go with the windows service option, which is I think a very good idea, I would suggest to use SignlaR to push messages between the client and the server. Windows service as a signalr client

Upvotes: 0

Related Questions