ClaimedMagneticStripeReader.EnableAsync ClaimedMagneticStripeReader.EnableAsync ClaimedMagneticStripeReader.EnableAsync ClaimedMagneticStripeReader.EnableAsync ClaimedMagneticStripeReader.EnableAsync Method

Definition

Gets the magnetic stripe reader into a ready state to receive data events.

public : IAsyncAction EnableAsync()
IAsyncAction EnableAsync() const;
public IAsyncAction EnableAsync()
Public Function EnableAsync() As IAsyncAction
Windows.Devices.PointOfService.ClaimedMagneticStripeReader.enableAsync().done( /* Your success and error handlers */ );

Returns

No object or value is returned by this method when it completes.

Examples

// Enables the magnetic stripe reader to receive data.
task<void> Scenario1::EnableReader()
{
    return create_task(_claimedReader->EnableAsync()).then([this](void)
    {
        // UpdateReaderStatusTextBlock("Magnetic stripe reader enabled successfully.");
    });

}
    // Enables the magnetic stripe reader to receive data
    private async Task<bool> EnableReader()
    {

        await _claimedReader.EnableAsync();
        return true;
    }
//Creates the magnetic stripe reader, claims it for exclusive use, adds a data event listener, 
//and enables it to receive data.
var _reader = null;
var _claimedReader = null;

function startRead() {
    Windows.Devices.PointOfService.MagneticStripeReader.getDefaultAsync().then(function (reader) {
        if (reader !== null) {
            _reader = reader;
            
            reader.claimReaderAsync().done(function (claimedReader) {
                _claimedReader = claimedReader;
                claimedReader.isDecodeDataEnabled = true;
               
                claimedReader.addEventListener("bankcarddatareceived", onBankCardDataReceived);
                claimedReader.enableAsync().done(function () {
                   
                    document.getElementById("startReadButton").disabled = true;
                    document.getElementById("endReadButton").disabled = false;
                }, function error(e) {
                    // "Failed to enable the magnetic stripe reader."
                });
            }, function error(e) {
                //"Could not claim the magnetic stripe reader."
            });
        }
        else {
            //"Could not claim the magnetic stripe reader."
        }
           
    }, function error(e) {
        //"Magnetic stripe reader not found. Connect a magnetic stripe reader."
    });
}

See also