MagneticStripeReader.GetDefaultAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the first magnetic stripe reader found.
public:
static IAsyncOperation<MagneticStripeReader ^> ^ GetDefaultAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<MagneticStripeReader> GetDefaultAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<MagneticStripeReader> GetDefaultAsync();
function getDefaultAsync()
Public Shared Function GetDefaultAsync () As IAsyncOperation(Of MagneticStripeReader)
Returns
The first magnetic stripe reader found. Returns a null object in the following cases:
- A device is not found.
- Access denied to the existing device. The user can deny access to a device, which is not treated as an exception.
- Attributes
Examples
// Creates the magnetic stripe reader.
task<void> Scenario1::CreateDefaultReaderObject()
{
return create_task(MagneticStripeReader::GetDefaultAsync()).then([this] (MagneticStripeReader^ reader)
{
_reader = reader;
if (_reader != nullptr)
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader created.");
// UpdateReaderStatusTextBlock("Device Id is:" + _reader->DeviceId);
}
else
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader not found. Connect a magnetic stripe reader.");
}
});
}
//Creates a magnetic stripe reader.
private async Task<bool> CreateDefaultMagneticStripeReaderObject()
{
if (_reader == null)
{
_reader = await MagneticStripeReader.GetDefaultAsync();
if (_reader != null)
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader created.");
// UpdateReaderStatusTextBlock("Device Id is:" + _reader.DeviceId);
}
else
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader not found. Connect a magnetic stripe reader.");
return false;
}
}
return true;
}