public Task <bool> InitializePrinterAsync() { var t = new TaskCompletionSource <bool>(); PrinterCallback callback = new PrinterCallback(); callback.RunResult += (o, e) => t.TrySetResult(e && GetPrinterStatus() == PrinterStatus.Ready); Printer.PrinterInit(callback); return(t.Task); }
public Task <bool> SendEscPosCommandsAsync(byte[] commands) { var t = new TaskCompletionSource <bool>(); PrinterCallback callback = new PrinterCallback(); callback.ReturnString += (o, e) => t.TrySetResult(e == "CACHE PRINTDATA DATA OK!"); Printer.SendUserCMDData(commands, callback); return(t.Task); }
public Task <bool> PerformPrintAsync() { PrinterStatus printerStatus = GetPrinterStatus(); if (printerStatus != PrinterStatus.Ready) { return(Task.FromResult(false)); } var t = new TaskCompletionSource <bool>(); PrinterCallback cb = new PrinterCallback(); cb.ReturnString += (o, e) => t.TrySetResult(e == "UserCMDData is Paesed OK!"); Printer.PrinterPerformPrint(0, cb); return(t.Task); }