MagneticStripeReader.ClaimReaderAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
尝试获取对磁条读取器的独占访问权限。
public:
virtual IAsyncOperation<ClaimedMagneticStripeReader ^> ^ ClaimReaderAsync() = ClaimReaderAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<ClaimedMagneticStripeReader> ClaimReaderAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<ClaimedMagneticStripeReader> ClaimReaderAsync();
function claimReaderAsync()
Public Function ClaimReaderAsync () As IAsyncOperation(Of ClaimedMagneticStripeReader)
返回
方法完成后,它将返回 ClaimedMagneticStripeReader ;如果操作无法声明磁条读取器,则返回 null。
- 属性
示例
// Claims the magnetic stripe reader for exclusive use
task<void> Scenario1::ClaimReader()
{
return create_task(_reader->ClaimReaderAsync()).then([this] (ClaimedMagneticStripeReader^ claimedReader)
{
_claimedReader = claimedReader;
if (_claimedReader != nullptr)
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader claimed successfully.");
}
else
{
// UpdateReaderStatusTextBlock("Failed to claim the magnetic stripe reader.");
}
});
}
// Claims the magnetic stripe reader for exclusive use.
private async Task<bool> ClaimReader()
{
if (_claimedReader == null)
{
_claimedReader = await _reader.ClaimReaderAsync();
if (_claimedReader != null)
{
// UpdateReaderStatusTextBlock("Magnetic stripe reader claimed successfully.");
}
else
{
// UpdateReaderStatusTextBlock("Failed to claim a magnetic stripe reader.");
return false;
}
}
return true;
}