BarcodeScanner.ClaimScannerAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
嘗試取得條碼掃描器的獨佔存取權。
public:
virtual IAsyncOperation<ClaimedBarcodeScanner ^> ^ ClaimScannerAsync() = ClaimScannerAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<ClaimedBarcodeScanner> ClaimScannerAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<ClaimedBarcodeScanner> ClaimScannerAsync();
function claimScannerAsync()
Public Function ClaimScannerAsync () As IAsyncOperation(Of ClaimedBarcodeScanner)
傳回
方法完成時,它會傳回 ClaimedBarcodeScanner。
- 屬性
範例
// Claims the barcode scanner for exclusive use
task<void> Scenario1::ClaimScanner()
{
return create_task(scanner->ClaimScannerAsync()).then([this] (ClaimedBarcodeScanner^ _claimedScanner)
{
this->claimedScanner = _claimedScanner;
if (claimedScanner != nullptr)
{
// UpdateOutput("Barcode scanner claimed successfully.");
}
else
{
// UpdateOutput("Failed to claim barcode scanner.");
}
});
}
// Claims the barcode scanner for exclusive use.
private async Task<bool> ClaimScanner()
{
if (claimedScanner == null)
{
claimedScanner = await scanner.ClaimScannerAsync();
if (claimedScanner != null)
{
// UpdateOutput("Barcode scanner claimed successfully.");
}
else
{
// UpdateOutput("Failed to claim the barcode scanner.");
return false;
}
}
return true;
}