|
楼主 |
发表于 2016-6-2 14:48:19
|
显示全部楼层
private void toolStripButton2_Click(object sender, EventArgs e)
{
Thread thread = new Thread(Captures);
thread.Start();
}
private void Captures()
{
bool retry;
do
{
retry = false;
try
{
Control.CheckForIllegalCrossThreadCalls = false;
DeviceManager.SelectedCameraDevice.IsBusy = false;
DeviceManager.SelectedCameraDevice = (ICameraDevice)comboBox1.SelectedItem;
DeviceManager.SelectedCameraDevice.CapturePhoto();
DeviceManager.SelectedCameraDevice = (ICameraDevice)comboBox2.SelectedItem;
DeviceManager.SelectedCameraDevice.CapturePhoto();
}
catch (DeviceException exception)
{
if (exception.ErrorCode == ErrorCodes.MTP_Device_Busy || exception.ErrorCode == ErrorCodes.ERROR_BUSY)
{
// this may cause infinite loop
Thread.Sleep(100);
retry = true;
}
else
{
MessageBox.Show("Error occurred :" + exception.Message);
}
}
} while (retry);
} |
|