We started principal development on the Bio Approval Workflow project (see here and here), and I realized that I could make people’s lives easier by simpifying the fingerprint authentication demo code I checked into Codeplex a couple of weeks ago.
What was originally present was a (native) helper dll that required the caller to use three different functions (Initialize, Identify, and Uninitialize), as well as provide a callback, just to do one thing: perform a fingerprint scan and, if successful, determine whether it maps to the currently logged-on user.
That probably sounds harder than it is – see the Codeplex link above to check out the code. Anyway, now that we started writing the real application code, which I knew was going to be all C#, it occurred to me that I could make things much easier in the native code helper dll. Specifically:
- Provide a new helper export that does the initialize, identify, and uninitialize for you.
- Make it synchronous, so it doesn’t require the callback. While I’m hoping that the synchronous approach won’t be a problem for WPF (e.g., disrupt UI threads like in Win32), even if it does, it’s easy to spin up a separate managed thread to work around that.
- Write a P/Invoke helper class for accessing that export from managed code, as well as a managed console application for testing it.
That whole procedure took me less than an hour, since I was already familiar with the underlying code, as well as the new biometric interfaces. If I’d instead waited for the application developer to slog through that – or worse, having him write and test a P/Invoke wrapper for the original asynchronous model – it would have taken much longer. Lesson learned.