ESC-POS-.NET icon indicating copy to clipboard operation
ESC-POS-.NET copied to clipboard

BasePrinter Dispose() method block printing

Open emanuhell opened this issue 2 years ago • 3 comments

BasePrinter Dispose() method block printing. For example:

printer.Write(e.Initialize());
printer.Write(e.Enable());
printer.Write(Tests.Receipt(e));
printer.Dispose();

prints nothing! I need the Dispose method to release the connection to the printer after each print, to allow other running applications to use the same printer. Thanks.

emanuhell avatar Jan 23 '23 13:01 emanuhell

Which printer are you using? Some of the implementations are asynchronous (Writes are buffered and flushed by a task). This is to increase the performance of many small writes. You may just be disposing the connection before the flush happens. We should probably expose a way to await the print queue being empty.

lukevp avatar Jan 27 '23 18:01 lukevp

Which printer are you using? I'm using the SerialPrinter.

We should probably expose a way to await the print queue being empty. What method are you talking about? I can't find it.

Thanks.

emanuhell avatar Jan 30 '23 08:01 emanuhell

Sorry for digging this up but what is the difference between version 1.6 (which works fine) and 3.0?

After it prints the first time, I'm facing an error

System.IO.IOException: Device or resource busy : '/dev/usb/lp3'

I tried both options

var printerLinUsb = new FilePrinter(filePath: '/dev/usb/lp3'`, false);
...
printerLinUsb.Dispose();

and

using (var printerLinUsb = new FilePrinter(filePath: '/dev/usb/lp3'`, false))
{
...
}

mtarlac avatar Aug 13 '24 11:08 mtarlac