我使用的插件无论何时将指纹识别器插入计算机都可以注册。这是由事件完成的。事件被触发,读者被添加到List。
在Visual Studio中运行应用程序时,一切正常。该服务正在启动'通过在WPF UI应用程序中实例化实例。
当我安装服务时(WPF UI断开连接但是创建了一个服务逻辑实例并启动了一个线程),一切正常。日志显示正在运行订阅事件的初始代码。此代码如下所示:
public GriauleReader()
{
log.Debug("Loading the GrFingerLib library");
if (FingerXCtrlClass != null)
{
// Subscribe to the plug, unplug and imageAcquired events from the GrFingerXCtrlClass library.
FingerXCtrlClass.SensorPlug += ReaderPlug;
FingerXCtrlClass.SensorUnplug += ReaderUnplug;
FingerXCtrlClass.ImageAcquired += ImageAcquired;
log.Debug("Successfully registered for the events sent by a Griaule fingerprint reader.");
}
}
正如我之前所说,从Visual Studio运行时,这是有效的。当作为服务安装时,上面的代码也会被执行。不幸的是,ReaderPlug
仅在Visual Studio(WPF实例)中运行应用程序时被调用。
public override void ReaderPlug(string readerId)
{
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
if (!(string.IsNullOrEmpty(readerId)))
{
if (!readerId.Equals("File"))
{
log.Debug("Reader pluggedin event of GriauleReader is received and start processing...");
// Send an event to the FingerprintReaderLogic to notify that there is new reader plugged in.
DispatchReaderPluggedInEvent(readerId, GetFingerprintReaderType());
}
}
else
{
log.Error(
"No reader id is received. Plugin event has no reader id. Plugged reader cannot be added to the system.");
}
}
我自己认为因为线程而出现问题。也许最初的线程被杀死或类似的东西。可能是所述问题的原因,有没有办法检查某些线程是否存在?