日期:2014-05-17 浏览次数:20912 次
if (threadJoyStickMaxon != null && threadJoyStickMaxon.IsAlive)
{
joyStickLeftPortKeepReading = false;
threadJoyStickMaxon.Join();
threadJoyStickMaxon = null;
}
void CreateManageThreadDeviceInit()
{
threadDeviceInit = new Thread(ManageThreadDeviceInit);
threadDeviceInit.Start();
}
void ManageThreadDeviceInit()
{
OpenJoystickerLeftport();
InitMaxon();
joyStickLeftPortKeepReading = true;
CreateManageThreadJoystickMaxon();
CreateManageThreadReadMaxonStatus(); //打开读电机状态线程
deviceInitThreadResetEvent.WaitOne(); //**MJ:让初始化硬件线程阻塞,直到关闭软件的时候在唤醒它,关闭Maxon电机连接
try //关闭电机连接,电机API提供的方式
{
maxonErrorPromptMessage = "CloseDevice"; //**MJ:如果没有成功打开Maxon电机,关闭Maxon电机连接时或者不关,都会有VC++ RunTime Library Error,定时器初始化设备有时也会,线程初始化设备是每次都有
if (EposCmd.Net.VcsWrapper.Device.VcsCloseDevice(keyHandle, ref errorCode) == 0)