好吧......所以这看起来应该是一个 super 简单的 - 我需要禁用符号条形码扫描仪,做一些工作,然后重新启用扫描仪。
我有一个工作正常的扫描仪类,因此我在我的项目查找类中尝试了以下代码
private Symbol.Barcode.Reader MyReader = Scanner.GetMyReader;//gets the reader
.....
......
private method()
{
MyReader.Actions.Disable();
...do some work here
MyReader.Actions.Enable()
}
上述代码的问题是阅读器似乎永远不会重新启用,尤其是。激光永远不会重新亮起,并且读取通知事件也永远不会再次触发。
我还尝试了 MyReader.ReadNotify -= MyReader_ReadNotify; 然后将其添加回来,但这也不起作用,因为按下扫描按钮时扫描仪仍然会构建扫描事件。
我确实尝试了 MyReader.Actions.Read(MyReaderData),这再次触发了读取事件,但仍然没有启用扫描仪。
在 MyReader.Actions.Enable() 之后需要添加一些内容吗?
我已经搜索了几个小时,但没有解决这个问题。
谢谢
最佳答案
根据 Motorola EMDK 指南,您只需要三种方法和适当的事件处理程序:
引用
启用阅读器
启用扫描仪硬件。此方法不会使扫描仪扫描或打开激光。
// Enable the Reader
MyReader.Actions.Enable();
提交读取请求
开始挂起的读取。该方法不会打开激光。然而,它会将扫描仪置于 可以通过按下硬件触发器或执行以下操作来打开激光的状态 作为软件触发器。
// Submit a read
MyReader.Actions.Read(this.MyReaderData);
即使提交了读取请求并成功读取完成,获取数据也需要事件 处理程序。请参阅注册到扫描仪通知部分以创建事件处理程序。
禁用阅读器
禁用扫描仪硬件。反转启用过程。扫描仪必须先重新启用,然后才能使用 如果已禁用则使用。
// Disable the reader
this.MyReader.Actions.Disable();
注意:禁用读取器时,必须考虑有关通知处理程序的以下事项。为了 有关通知的信息,请参阅“注册扫描仪通知”部分。
Status notification handler: A previously attached StatusNotify event handler will be automatically
detached. When the reader is re-enabled, the event handler must be re-attached to get further status
notifications.
Read notification handler: A previously attached ReadNotify event handler will not be detached. It
gets detached only when the reader is disposed.
/引用
这意味着你必须使用:
this.MyReader.Actions.Disable();
和
MyReader.Actions.Enable();
并重新附加通知处理程序。 当您发出问题时,扫描仪就会亮起
MyReader.Actions.Read(this.MyReaderData);
可能您必须按下扫描按钮才能触发扫描仪点亮。
关于c#-3.0 - 禁用然后重新启用符号条形码扫描仪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20336785/