I am developing a small application and use this project as the basis for accessing devices through an adb socket:
http://madb.codeplex.com
My code in the constructor of the main form:
if (useMadBee())
{
BridgeContainer.manager.adb.
DeviceChanged += new EventHandler<DeviceEventArgs>(beeDeviceChanged);
BridgeContainer.manager.adb.
DeviceConnected += new EventHandler<DeviceEventArgs>(beeDeviceConnected);
BridgeContainer.manager.adb.
DeviceDisconnected += new EventHandler<DeviceEventArgs>(
beeDeviceDisconnected);
}
where adb is AndroidDebugBruidge (class from MadBee)
This is one of my EventHandlers:
public void beeDeviceConnected(object sender, DeviceEventArgs e)
{
if (((string)dev_con_synclock).Equals("y"))
{
dev_con_synclock = "n";
lock (dev_con_synclock)
{
List<Device> lista = BridgeContainer.manager.adb.Devices;
connectedDevices.Clear();
this.toolStripComboDevices.Items.Clear();
foreach (Device d in lista)
{
AndroidDevice newDevice = new AndroidDevice();
newDevice.modelName = d.Properties["ro.build.product"].ToString();
newDevice.deviceSerialNumber = d.SerialNumber;
this.toolStripComboDevices.Items.Add(
newDevice.modelName + "(" + newDevice.deviceSerialNumber + ")");
connectedDevices.Add(newDevice);
}
if (connectedDevices.Count > 0)
{
toolStripComboDevices.Text = toolStripComboDevices.Items[0].ToString();
}
else
{
toolStripComboDevices.Text = "";
}
}
dev_con_synclock = "y";
}
}
And around the line
List<Device> lista = BridgeContainer.manager.adb.Devices;
methods stop execution, the program continues to live. When I debug this line, I see that everything works fine in this line method (I get a collection of devices), and suddenly the program switches to DeviceMonitorLoop in DeviceMonitor MadB and ends in a couple of loops.
The foreach block (device d in the list) is never executed in my program, for some strange reason the method will not continue to execute
?
, (.. ) (, , 3 ),
, beeDeviceConnected ( , DeviceEventArgs e) ?