Esempio n. 1
0
        /// <summary>
        /// Shuts down the EyeTracking host.
        /// </summary>
        public void Shutdown()
        {
            _isShuttingDown = true;

            if (!IsInitialized)
            {
                return;
            }
            print("Tobii EyeTracking is shutting down.");

            if (_context != null)
            {
                // The context must be shut down before disposing.
                try
                {
                    _context.Shutdown(1000, false);
                }
                catch (InteractionApiException ex)
                {
                    Debug.LogError("Tobii Engine context shutdown failed: " + ex.Message);
                }

                _context.Dispose();
                _context = null;
            }

            if (_environment != null)
            {
                _environment.Dispose();
                _environment = null;
            }
        }
        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        /// <param name="isDisposing">true if managed resources should be disposed; otherwise, false.</param>
        protected virtual void Dispose(bool isDisposing)
        {
            if (isDisposing)
            {
                if (_context != null && !_context.IsInvalid)
                {
                    // The context must be shut down before disposing.
                    try
                    {
                        _context.Shutdown();
                    }
                    catch (InteractionApiException ex)
                    {
                        Debug.WriteLine("EyeX context shutdown failed: " + ex.Message);
                    }

                    _context.Dispose();
                    _context = null;
                }

                if (_environment != null)
                {
                    _environment.Dispose();
                    _environment = null;
                }
            }
        }