BarcodeScanner.ClaimScannerAsync Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Tenta di ottenere un accesso esclusivo allo scanner di codice a barre.
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)
Restituisce
Al termine del metodo, restituisce un ClaimedBarcodeScanner.
- Attributi
Esempio
// 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;
}