Frameworks > Bluetooth Framework

UI Thread Locks while calling InRange

(1/2) > >>

servel333:
When I call wclnet.wclBluetoothDevice.InRange(radio) from a background thread, the UI on my application appears to lock up and is not responsive.

Computer
   Dell Optiplex 745
Language: Visual Basic 2005
Stack: Microsoft
Driver: Microsoft
   Version: 5.1.2600.2180
   C:\WINDOWS\system32\bthprops.cpl
   C:\WINDOWS\system32\DRIVERS\bthport.sys
   C:\WINDOWS\system32\DRIVERS\BTHUSB.SYS
   C:\WINDOWS\system32\fsquirt.exe
Bluetooth Dongle
   AluraTek  ABD2020
   USB Version 2.0
   VID 0x0A12
   PID 0x0001
   Bluetooth Version 2.0
   Class 2

Mike Petrichenko:
How do you call this?

servel333:
Sorry about the delayed response to your question.

We have a dialog that continuously performs discovery for Bluetooth devices through a radio.  When discovery completes, the list is filtered for the class of device we are looking for.  Each device is then checked to determine if it is in range to prevent 'ghosting' of devices no longer detected.  After all of this is completed, the discovery process is repeated until the dialog is closed.

This all occurs in a background thread.  I noticed when the discovery process completes (wclnet.wclBluetoothDiscovery.DiscoveryComplete) it happens on the main UI thread, so I save the list of detected devices and then a background thread receives the list and processes them.  The actual call to InRange occurs in this background thread.

I have observed the UI freezing on regular intervals, and it appears to be during the background threads operation.  If I break execution during the freezing, the process is always stopped at InRange and I have verified it is being called on a background thread, not the UI thread.

Mike Petrichenko:
It happens because the object was created in the main thread.

servel333:
I set up a background thread specifically to initialize the wclnet.wclAPI and wclnet.wclBluetoothDiscovery objects, however when the code Me._library = New wclnet.wclAPI is executed in the background thread, it throws an exception.

In addition to this, it appears the exception is either disposed or set to an incorrect memory location before it gets to the Catch ex As Exception statement because it shows "Error: Cannot obtain value" when I examine it in the development environment.  Also, when I get to code that attempts to read any field in the exception object, my application simply exits without warning.

In this case I am using a BackgroundWorker to create the background thread and calling all of the above code in the DoWork() event.

Navigation

[0] Message Index

[#] Next page

Sitemap 1 2 3 4 5 6 7 
Go to full version