private static void DisconnectSession() { if (asyncConnection != null && asyncConnection.IsRunning()) { try { asyncConnection.Disconnect(1); } catch (Exception ex) { //Do nothing } } }
public bool ConnectCreo() { try { if (asyncConnection == null || !asyncConnection.IsRunning()) { asyncConnection = new CCpfcAsyncConnection().Connect(null, null, null, null); return(true); } else { return(false); } } catch { return(false); } }
private Timer eventTimer; //定时器,用于定时处理asyncConnection.EventProcess,防止Creo无法处理事件导致程序锁死 /// <summary> /// 连接现有会话并添加菜单 /// </summary> /// <returns>是否连接成功</returns> public bool ConnectCreo() { try { if (asyncConnection == null || asyncConnection.IsRunning() == true) { asyncConnection = new CCpfcAsyncConnection().Connect(null, null, null, null); AddEventProcess(); AddPushButtonMenu(); return(true); } else { return(false); } } catch { return(false); } }