Bluetooth printer discoverer starts using a lot of CPU when using Zebra SKD

Y Yanis Dalabiras 2 years ago
19 0 0

I am building a service that is always open on the computer and connected to a Bluetooth printer. When the printer is discovered and is being shut down (via button), the service immediately starts using something like 40% of the CPU. And when the printer is turned ON, the service doesn't stop using 30-40% of the CPU until I programmatically won't find a connection on my own.
What is this and how can I disable this feature?

Printer discoverer code:
DiscoveredPrinter discoveredPrinter = null;
BluetoothDiscoveryHandler discoveryHandler = new BluetoothDiscoveryHandler();
BluetoothDiscoverer.FindPrinters(discoveryHandler);

while (!discoveryHandler.DiscoveryComplete)
{
Task.Delay(10).Wait();
}

discoveredPrinter = discoveryHandler.DiscoveredPrinter;

private class BluetoothDiscoveryHandler : DiscoveryHandler
{
private bool discoveryComplete = false;
public DiscoveredPrinter DiscoveredPrinter;

public void DiscoveryError(string message)
{
//Console.WriteLine($"An error occurred during discovery: {message}.");
discoveryComplete = true;
}

public void DiscoveryFinished()
{
discoveryComplete = true;
}

public void FoundPrinter(DiscoveredPrinter printer)
{
//Console.WriteLine("Printer found: " + printer.Address);
if (printer.Address == ConfigData.PrinterMACAddress)
{
discoveryComplete = true;
DiscoveredPrinter = printer;
}
}

public bool DiscoveryComplete
{
get => discoveryComplete;
}
}

CONTACT
Can’t find what you’re looking for?