CashDrawer.WaitForDrawerClose 期间事件堆积
我正在编写 POS 应用程序并使用 POS for .NET。我发现,当我调用 WaitForDrawerClose 方法时,虽然应用程序将无响应地等待直到抽屉关闭(根据需要),但其他地方的任何点击似乎都会堆积在队列中,并且一旦抽屉关闭,所有点击都会触发。只要 WaitForDrawerClose 尚未返回,如何让我的应用程序停止侦听这些事件?谢谢!
I'm writing an application for a POS and using POS for .NET. I've found that when I call the WaitForDrawerClose method, while the application will sit and wait unresponsively until the drawer is closed (as desired), any clicks elsewhere seem to pile up in the queue and all fire once the drawer has been closed. How can I make my app stop listening for these events so long as WaitForDrawerClose has not yet returned? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以完全避免调用 WaitForDrawerClose,并自行处理逻辑。
只需收听 OnDrawerStateChanged 事件来通知抽屉何时关闭。这将让您退出例程,更新 UI(禁用按钮以防止事件触发等),然后在抽屉关闭时干净地重新启用所有内容,而不是在该点同步阻塞(这会导致您的问题) 。
这需要花费更多的精力,因为它比单行方法需要更多的工作,但是如果用户没有执行他们应该执行的操作,它可以让您更好地控制应用程序的反应方式。您甚至可以让导航屏幕告诉用户(在一定的延迟后)他们需要关闭抽屉,执行比标准蜂鸣声更多的操作等。
You could avoid calling WaitForDrawerClose entirely, and handle the logic yourself.
Just listen for the OnDrawerStateChanged event instead to tell when the drawer is closed. Instead of synchronously blocking at that point (which is causing your problem), this would let you just exit your routine, update your UI (disable buttons to prevent events from firing, etc), and then re-enable everything cleanly when the drawer closes.
It's a bit more effort, since it's more work than a one line method, but it gives you a LOT more control over how your application will react if the user doesn't do what they're supposed to do. You even could have nag screens tell the user (after a certain delay) that they need to close the drawer, do more than the standard beeping, etc.