예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Closes the connection to Libronix
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void Close()
        {
            lock (this)
            {
                if (m_PositionChangedBridge != null)
                {
                    if (m_cookies != null)
                    {
                        RemovePositionEvents();
                    }
                    m_PositionChangedBridge.PositionChanged -= OnPositionChangedInLibronix;
                }
                m_PositionChangedBridge = null;
                m_cookies.Clear();
                if (m_pollTimer != null)
                {
                    m_pollTimer.Stop();
                    m_pollTimer.Dispose();
                    m_pollTimer = null;
                }

                if (m_ApplicationEventsBridge != null)
                {
                    try
                    {
                        m_ApplicationEventsBridge.Disconnect(m_libronixApp, m_ApplicationEventsCookie);
                    }
                    catch
                    { }
                    m_ApplicationEventsBridge.EventFired -= OnApplicationEventsBridgeEventFired;
                }
                m_ApplicationEventsBridge = null;

                m_libronixApp = null;
            }
        }
예제 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Closes the connection to Libronix
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void Close()
		{
			lock (this)
			{
				if (m_PositionChangedBridge != null)
				{
					if (m_cookies != null)
						RemovePositionEvents();
					m_PositionChangedBridge.PositionChanged -= OnPositionChangedInLibronix;
				}
				m_PositionChangedBridge = null;
				m_cookies.Clear();
				if (m_pollTimer != null)
				{
					m_pollTimer.Stop();
					m_pollTimer.Dispose();
					m_pollTimer = null;
				}

				if (m_ApplicationEventsBridge != null)
				{
					try
					{
						m_ApplicationEventsBridge.Disconnect(m_libronixApp, m_ApplicationEventsCookie);
					}
					catch
					{ }
					m_ApplicationEventsBridge.EventFired -= OnApplicationEventsBridgeEventFired;
				}
				m_ApplicationEventsBridge = null;

				m_libronixApp = null;
			}
		}
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initalizes the Libronix COM objects.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void Initalize()
        {
            try
            {
                // If Libronix isn't running, we'll get an exception here
                object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");

                m_libronixApp = libApp as LbxApplication;
            }
            catch (COMException e)
            {
                if ((uint)e.ErrorCode == 0x800401E3)                 // MK_E_UNAVAILABLE
                {
                    if (m_fStart)
                    {
                        try
                        {
                            // try to start
                            m_libronixApp         = new LbxApplicationClass();
                            m_libronixApp.Visible = true;
                        }
                        catch (Exception e1)
                        {
                            Debug.Fail("Got exception in Initialize trying to start Libronix: " + e1.Message);
                            m_libronixApp   = null;
                            s_fNotInstalled = true;
                        }
                    }
                    else
                    {
                        m_libronixApp = null;
                        StartTimer();
                    }
                }
                else
                {
                    s_fNotInstalled = true;
                }
            }
            catch (Exception e)
            {
                Debug.Fail("Got exception in Initialize trying to get running Libronix object: " + e.Message);
            }
            if (m_libronixApp == null)
            {
                return;
            }

            // The commented-out lines are necessary to receive sync messages from Libronix, but currently
            // they cause a crash (in release builds only! beware!).
            // We may be able to create this object in a separate AppDomain. This has not yet been tried.
            // Various and confusing error messages come up and exceptions get thrown within the method.
            // (See TE-6457.) If we don't otherwise get a fix, it may be worth anothe try when we upgrade
            // to the next version of ICU, because the problem is something to do with not being able
            // to find an ICU method...possibly some of Libronix's marshalling code is messed up by our
            // version of ICU??
            m_PositionChangedBridge = null;
            StartPollTimer();
            //m_PositionChangedBridge = new LbxResourcePositionChangedBridgeClass();
            //m_PositionChangedBridge.PositionChanged +=
            //    new DLbxResourcePositionChanged_PositionChangedEventHandler(OnPositionChangedInLibronix);

            m_ApplicationEventsBridge             = new LbxApplicationEventsBridgeClass();
            m_ApplicationEventsBridge.EventFired += new DLbxApplicationEvents_EventFiredEventHandler(OnApplicationEventsBridgeEventFired);
            m_ApplicationEventsCookie             = m_ApplicationEventsBridge.Connect(m_libronixApp);

            SetupPositionEvents();
        }
예제 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initalizes the Libronix COM objects.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void Initalize()
		{
			try
			{
				// If Libronix isn't running, we'll get an exception here
				object libApp = Marshal.GetActiveObject("LibronixDLS.LbxApplication");

				m_libronixApp = libApp as LbxApplication;
			}
			catch (COMException e)
			{
				if ((uint)e.ErrorCode == 0x800401E3) // MK_E_UNAVAILABLE
				{
					if (m_fStart)
					{
						try
						{
							// try to start
							m_libronixApp = new LbxApplicationClass();
							m_libronixApp.Visible = true;
						}
						catch (Exception e1)
						{
							Debug.Fail("Got exception in Initialize trying to start Libronix: " + e1.Message);
							m_libronixApp = null;
							s_fNotInstalled = true;
						}
					}
					else
					{
						m_libronixApp = null;
						StartTimer();
					}
				}
				else
					s_fNotInstalled = true;
			}
			catch (Exception e)
			{
				Debug.Fail("Got exception in Initialize trying to get running Libronix object: " + e.Message);
			}
			if (m_libronixApp == null)
				return;

			// The commented-out lines are necessary to receive sync messages from Libronix, but currently
			// they cause a crash (in release builds only! beware!).
			// We may be able to create this object in a separate AppDomain. This has not yet been tried.
			// Various and confusing error messages come up and exceptions get thrown within the method.
			// (See TE-6457.) If we don't otherwise get a fix, it may be worth anothe try when we upgrade
			// to the next version of ICU, because the problem is something to do with not being able
			// to find an ICU method...possibly some of Libronix's marshalling code is messed up by our
			// version of ICU??
			m_PositionChangedBridge = null;
			StartPollTimer();
			//m_PositionChangedBridge = new LbxResourcePositionChangedBridgeClass();
			//m_PositionChangedBridge.PositionChanged +=
			//    new DLbxResourcePositionChanged_PositionChangedEventHandler(OnPositionChangedInLibronix);

			m_ApplicationEventsBridge = new LbxApplicationEventsBridgeClass();
			m_ApplicationEventsBridge.EventFired += new DLbxApplicationEvents_EventFiredEventHandler(OnApplicationEventsBridgeEventFired);
			m_ApplicationEventsCookie = m_ApplicationEventsBridge.Connect(m_libronixApp);

			SetupPositionEvents();
		}