/// <summary> ///Actual claim method task that claims and enables printer instance 2 asynchronously. It then adds the releasedevicerequested event handler as well to the claimed printer. /// </summary> private async Task <bool> ClaimAndEnablePrinter2() { if (printerInstance2 == null) { rootPage.NotifyUser("Cound not claim printer. Make sure you find printer first.", NotifyType.ErrorMessage); return(false); } if (printerInstance1 != null && claimedPrinter2 == null) { rootPage.NotifyUser("Trying to claim instance 2.", NotifyType.StatusMessage); claimedPrinter2 = await printerInstance2.ClaimPrinterAsync(); if (claimedPrinter2 != null) { claimedPrinter2.ReleaseDeviceRequested += ClaimedPrinter2_ReleaseDeviceRequested; rootPage.NotifyUser("Claimed Printer Instance 2", NotifyType.StatusMessage); if (!await claimedPrinter2.EnableAsync()) { rootPage.NotifyUser("Could not enable printer instance 2.", NotifyType.ErrorMessage); } else { return(true); } } else { rootPage.NotifyUser("Claim Printer instance 2 failed. Probably because instance 1 is holding on to it.", NotifyType.ErrorMessage); } } return(false); }
/// <summary> /// Actual claim method task that claims the printer asynchronously /// </summary> private async Task <bool> ClaimPrinter() { if (claimedPrinter == null) { claimedPrinter = await printer.ClaimPrinterAsync(); if (claimedPrinter != null) { rootPage.NotifyUser("Claimed Printer", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Claim Printer failed", NotifyType.ErrorMessage); return(false); } } return(true); }