我正在使用Panini银行支票扫描仪 我有一个控制器,可以从扫描仪接收不同的事件 一个事件如下:
//Connected
case 0:
DeviceConnectedEvent?.Invoke(this, vxargs);
break;
并且
public delegate void DeviceConnectedEventHandler(object sender, VisionXAPIEventArgs e);
public event DeviceConnectedEventHandler DeviceConnectedEvent;
protected void OnDeviceConnectedEvent(object sender, VisionXAPIEventArgs e)
{
DeviceConnectedEvent(this, e);
Application.DoEvents();
}
我的代码中有一个类可以处理所有扫描程序。包括接收这些事件。初始化此类时,我会调用每个事件:
scannerAPI.DeviceConnectedEvent += new APIControl.DeviceConnectedEventHandler(ScannerAPI_ScannerConnectEvent);
我现在的问题是,我的软件中有两个不同的位置,我需要调用此扫描仪并扫描检查。
当我创建一个扫描程序实例时,我向他发送了一个调用链接它们的窗口
在调用扫描程序的每个窗口中,我都有一个DeviceConnected方法,我想要被类调用,如下所示:
private void ScannerAPI_ScannerConnectEvent(object sender, VisionXAPIEventArgs e)
{
//Do some code linked to the scanner
CallerWindow.ScannerConnecteEvent();
}
但是当我这样做时,当我调用扫描仪扫描方法时,我看到扫描仪将实际窗口作为调用者窗口,当我收到事件时,我看到扫描仪窗口在扫描仪的实例上链接到我的其他窗口(主窗口,首先调用扫描仪的窗口) 我不知道我是否足够清楚,不要犹豫。