private void enumerateSAMsAndGetInfo()
        {
            if (samManager != null)
            {
                RunOnUiThread(() => txtStatus.Text = "");
                IList <SAM> samList = null;
                presetSAMList.Clear();
                try
                {
                    samList = samManager.EnumerateSAMs();
                }
                catch (SAMException ex)
                {
                    updateStatus(GetString(Resource.String.message_sam_exception_enumerate) + " " + SAMResults.GetErrorDescription(ex.Result));
                    return;
                }

                if ((samList != null) && (samList.Count != 0))
                {
                    int i = 0;
                    foreach (SAM sam in samList)
                    {
                        presetSAMList.Add(sam.SamIndex, sam);
                        getSAMInfo(sam);
                        i++;
                    }
                    enableDisableUIComponents(true);
                }
                else
                {
                    enableDisableUIComponents(false);
                    updateStatus(GetString(Resource.String.message_failed_to_get_sams));
                }
            }
        }
        private void getSAMInfo(SAM sam)
        {
            string text = "";

            if (sam != null)
            {
                long tick = DateTime.Now.Ticks;

                /** Connect [Start] */
                try
                {
                    if (!sam.IsConnected)
                    {
                        sam.Connect();
                        text += GetString(Resource.String.message_sam_connected_successfully) + " " + sam.SamType + "(Slot " + sam.SamIndex + ")\n";
                    }
                }
                catch (SAMException ex)
                {
                    updateStatus(GetString(Resource.String.message_connect_error) + " " + SAMResults.GetErrorDescription(ex.Result));
                    return;
                }
                /** Connect [End] */

                /** Transceive [Start] */
                byte[] getVersionAPDU = null;
                getVersionAPDUs.TryGetValue(sam.SamType, out getVersionAPDU);
                byte[] response = null;
                try
                {
                    text    += GetString(Resource.String.message_transceive) + "\n";
                    response = sam.Transceive(getVersionAPDU, (short)0, false);
                    if (response != null)
                    {
                        text += GetString(Resource.String.version) + " " + getHexString(response) + "\n";
                    }
                    else
                    {
                        text += GetString(Resource.String.version_error) + "\n";
                    }
                }
                catch (SAMException ex)
                {
                    text += GetString(Resource.String.message_transceive_failed) + " " + SAMResults.GetErrorDescription(ex.Result) + "\n";
                }
                /**Transceive [End] */

                /** Disconnect [Start] */
                if (sam.IsConnected)
                {
                    sam.Disconnect();
                    text += GetString(Resource.String.message_disconnecting) + " " + sam.SamType + "(Slot " + sam.SamIndex + ")\n";
                }
                /** Disconnect [End] */

                long timetook = (DateTime.Now.Ticks - tick) / 10000;
                text += "Time taken to get version: " + timetook + "ms";
                updateStatus(text);
            }
        }