Share via

BLE Disconnect Winforms application

Anonymous
2022-01-25T19:08:31.693+00:00

I have a winforms application that I using to connect/communicate to my BLE device. When I am finished with the object, I dispose of the services and then dispose the ble object. However, it won't connect again unless I close the application completely. Need to understand why and what a soulution might be. I even try to force the Garbage Collector. See code below.

public async void Dispose()
{
var services = await bleDevice.GetGattServicesAsync();
foreach (var service in services.Services)
{
service?.Session?.Dispose();
service?.Dispose();
}
bleDevice.Dispose();
bleDevice = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}

Developer technologies | Windows Forms

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.