背景:
我正在创建一个Windows 10通用应用程序,它从智能卡(插入到智能卡阅读器中)读取一些数据,并且工作正常,但是在任何情况下,用户都应该触发从智能卡读取数据的过程。
问题:
如何处理UWP中的“卡插入事件”,以便每次插入卡后都可以读取数据?
发布于 2016-11-25 17:30:19
我不熟悉UWP,但我找到了这个示例。
它创建一个智能卡读取器实例:
private SmartCardReader reader = provisioning.SmartCard.Reader;并向其添加一个CardAdded处理程序:
reader.CardAdded += HandleCardAdded;HandlerCardAdded看起来如下所示:
void HandleCardAdded(SmartCardReader sender, CardAddedEventArgs args)
{
// This event handler will not be invoked on the UI thread. Hence,
// to perform UI operations we need to post a lambda to be executed
// back on the UI thread; otherwise we may access objects which
// are not marshalled for the current thread, which will result in an
// exception due to RPC_E_WRONG_THREAD.
uiContext.Post((object ignore) =>
{
rootPage.NotifyUser("Card added to reader " + reader.Name + ".", NotifyType.StatusMessage);
}, null);
}希望这对你有一点帮助。
https://stackoverflow.com/questions/40786160
复制相似问题