Esempio n. 1
0
        /// <summary>
        /// Ensures the HB global initialize method has been called.
        /// </summary>
        public static void EnsureGlobalInit(bool initNoHardwareMode)
        {
            if (!globalInitialized)
            {
                try
                {
                    if (initNoHardwareMode)
                    {
                        initNoHardware = true;
                        if (hbFunctions.hb_global_init_no_hardware() == -1)
                        {
                            throw new InvalidOperationException("HB global init failed.");
                        }

                        initSuccess = true;
                    }
                    else
                    {
                        initSuccess = TryInit();
                    }
                }
                catch (Exception)
                {
                    initSuccess = false;
                }

                // Try without Hardware support. Bad drivers can sometimes cause issues.
                if (!initSuccess)
                {
                    if (hbFunctions.hb_global_init_no_hardware() == -1)
                    {
                        throw new InvalidOperationException("HB global init failed.");
                    }
                }

                globalInitialized = true;
            }
        }