开发者

WCF Async callback setup for polled device

开发者 https://www.devze.com 2022-12-22 11:38 出处:网络
I have a WCF service setup to control a USB fingerprint reader from our .Net applications. This works fine and I can ask it to enroll users and so on.

I have a WCF service setup to control a USB fingerprint reader from our .Net applications. This works fine and I can ask it to enroll users and so on.

The reader allows identification (it tells you that a particular user has presented their finger, as opposed to asking it to verify that a particular user's finger is present), but the device must be constantly polled while in identification mode for its status - when a user is detected the status changes.

What I want is for an interested application to notify the service that it wants to know when a user is identified, and provide a callback that gets triggered when this happens. The WCF service will return immediately and spawn a thread in the background to continuously poll the device. This polling could go on for hours at a time if no one tries to log in.

What's the best way to acheive this? My service contract is currently defined as follows:

[ServiceContract (CallbackContract=typeof(IBiometricCallback))]
public interface IBiometricWcfService
{
    ...
    [OperationContract (IsOneWay = true)]
    void BeginIdentification();
    ...
}

public interface IBiometricCallback
{
    ...
    [OperationContract(IsOneWay = true)]
    void IdentificationFinished(int aUserId, string aMessage, bool aSuccess);
   开发者_如何学Go ...
}

In my BeginIdentification() method can I easily spawn a worker thread to poll the device, or is it easier to make the WCF service asynchronous?


I think it is much better to make the WCF service operation asynchronously. This MSDN article shows how to do it:http://msdn.microsoft.com/en-us/library/ms730059.aspx.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号