Skip to content

onPtrReceive Method always calls on Main thread #18

@NirmitDagly

Description

@NirmitDagly

I need the whole printing feature in the background queue and I am running printing code in the background using the following functions:

DispatchQueue.background(delay: 0, attributes: .concurrent, background: {
globalGroup.enter()
self.printOrdersOnNotification()
})

and the following function starts the printing on Background Queue:

func printDocketsForOrder(order: PrintableOrder) {
print("Print orders from here...")
self.printList = [PrintableOrder]()
let printableOrder = order
for printer in self.printerList {
if printer.locationOfPrinter == printableOrder.docketType {
printerManagement.initializePrinterObject()
self.printerTarget = printer.printerTarget
print(printerManagement.printerTarget)
let printerIsConnected = printerManagement.connectPrinter()
if printerIsConnected == true {
//Print Docket for that particular order
let printOrder = printableOrder
printerManagement.printList.append(printOrder)
isPrinterSequenceRunning = printerManagement.runPrinterSequence()
}
else {
print("Printer is not connected...")
globalGroup.leave()
}
}
}
}

But the issue is that, I am always getting its callback -

func onPtrReceive(_ printerObj: Epos2Printer!, code: Int32, status: Epos2PrinterStatusInfo!, printJobId: String!)

on the main thread, instead of getting a call back on the background queue.

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions