private async void CardAdded(object sender, CardAddedEventArgs args)
 {
     Debug.WriteLine("Card Added");
     try
     {
         ChangeTextBlockFontColor(TextBlock_Header, Windows.UI.Colors.Green);
         await HandleCard(args);
     }
     catch (Exception ex)
     {
         PopupMessage("CardAdded Exception: " + ex.Message);
     }
 }
        /// <summary>
        /// Sample code to hande a couple of different cards based on the identification process
        /// </summary>
        /// <returns>None</returns>
        private async Task HandleCard(CardAddedEventArgs args)
        {
            try
            {
                card?.Dispose();
                card = args.SmartCard.CreateMiFareCard();

                var localCard = card;

                var cardIdentification = await localCard.GetCardInfo();


                DisplayText("Connected to card\r\nPC/SC device class: " + cardIdentification.PcscDeviceClass.ToString() + "\r\nCard name: " + cardIdentification.PcscCardName.ToString());

                if (cardIdentification.PcscDeviceClass == MiFare.PcSc.DeviceClass.StorageClass
                     && (cardIdentification.PcscCardName == CardName.MifareStandard1K || cardIdentification.PcscCardName == CardName.MifareStandard4K))
                {
                    // Handle MIFARE Standard/Classic
                    DisplayText("MIFARE Standard/Classic card detected");

                    var uid = await localCard.GetUid();
                    DisplayText("UID:  " + BitConverter.ToString(uid));

                    // 16 sectors, print out each one
                    for (var sector = 0; sector < 16 && card != null; sector++)
                    {
                        try
                        {
                            var data = await localCard.GetData(sector, 0, 48);

                            string hexString = "";
                            for (int i = 0; i < data.Length; i++)
                            {
                                hexString += data[i].ToString("X2") + " ";
                            }

                            DisplayText(string.Format("Sector '{0}':{1}", sector, hexString));

                        }
                        catch (Exception)
                        {
                            DisplayText("Failed to load sector: " + sector);
                        }
                    }
                    
                }
            }
            catch (Exception e)
            {
                PopupMessage("HandleCard Exception: " + e.Message);
            }
        }
        private static async void OnCardAdded(SmartCardReader sender, CardAddedEventArgs args)

        {
            try
            {

                await HandleCard(args.SmartCard);

                // Raise on UI thread
                context.Post(_ =>
                             {

                                 var evt = cardAdded;
                                 if (evt != null)
                                     evt(sender, EventArgs.Empty);
                             }, null);

            }
            catch (Exception ex)
            {
                // TODO: Add logging
                Debug.WriteLine(ex);
                
            }
            
        }