利用等待窗口的构造函数需要对类读者参考,注册一个OnCardReadEvent等待窗口。当收到事件时,调用reader类中的函数进行检查,如果需要继续显示等待窗口或关闭它。在OnCardReadEvent窗口关闭取消注册
如果您没有OnCardReadEvent然后创建一个。
内部时读做做这样的事情,使多个窗口,从一个单一的阅读器接收数据
DCardArrived _evnt = OnCardArrived; /*presumably declared event*/
Delegate[] _iList;
DCardArrived _Invoker;
if (_evnt != null)
{
_iList = _evnt.GetInvocationList();
for (int i = 0; i < _iList.Length; i++)
{
//You could also use BeginInvoke
_Invoker = (DCardArrived)_iList[i];
_Invoker.Invoke(this/*Sender*/,CardData/*class that inherits EventArgs containing the data either informing just the window to close or not or with the data for further processing*/);
}
}
你还没有给我们太多与:)
工作的读取器类你不是在寻找工厂模式吗? – CodingBarfield