2
我创建一个的Windows 10通用应用程序其读取智能卡的一些数据(插入智能卡阅读器),它工作正常,但在所有情况下,用户应该触发该过程从卡片读取数据。
问:
我怎样才能处理好“插入卡事件”在UWP,所以我可以将其插入后,每次读取卡上的数据?
我创建一个的Windows 10通用应用程序其读取智能卡的一些数据(插入智能卡阅读器),它工作正常,但在所有情况下,用户应该触发该过程从卡片读取数据。
问:
我怎样才能处理好“插入卡事件”在UWP,所以我可以将其插入后,每次读取卡上的数据?
我不熟悉UWP,但是我发现这个example。
它创建了一个智能卡读卡器如:
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);
}
希望这可以帮助您一点。