Microsoft OPOS hangs on Claim after PC restart

139 views Asked by At

I am using 'Microsoft Point of Service for .NET v1.14.' dlls to connect with Posiflex Thermal Printer (PP8800 model). Code snippet which I am using is also pasted below. I am running this code from WPF application.

But I am facing one strange issue. If printer is powered on and machine on which the printer is connected is restarted, below pasted code is not able to claim the printer and it also does not come out of the Claim() statement. Whereas if I power off the printer and then power it on before running the below code snippet then it is able to claim the printer.

PosExplorer posExplorer = new PosExplorer();
var printerList = posExplorer.GetDevices(DeviceType.PosPrinter);

foreach (DeviceInfo item in printerList)
{
    if (item.ServiceObjectName != printerName)
        continue;

    posPrinter = (PosPrinter)posExplorer.CreateInstance(item);
    posPrinter.Open();

    posPrinter.PowerNotify = PowerNotification.Enabled;
    posPrinter.FlagWhenIdle = true;
    posPrinter.StatusUpdateEvent += PosPrinter_StatusUpdateEvent;
    posPrinter.DirectIOEvent += PosPrinter_DirectIOEvent;
    posPrinter.ErrorEvent += PosPrinter_ErrorEvent;
    posPrinter.OutputCompleteEvent += PosPrinter_OutputCompleteEvent;

    try
    {
        posPrinter.Claim(100);
        if (posPrinter.Claimed)
        {
            isPrinterClaimed = true;                           
        }
        else
        {    
            isPrinterClaimed = false;
        }
    }
    catch (Exception ex)
    {
        isPrinterClaimed = false;
    }

    break;
}

Has anybody faced the same issue while using OPOS libraries?

0

There are 0 answers