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;
}