示例#1
0
        internal static void EnsureCatalogIsLoaded()
        {
            if (m_hasLoadedCatalog)
            {
                return;
            }

            bool gotLock = false;

            try {
                gotLock = Monitor.TryEnter(m_lockForCatalogLoad, TimeSpan.FromSeconds(20));
                if (!gotLock)
                {
                    string msg = StringExtensions.Fi("Thread '{0}' timed out while waiting on lock for loading the Syntax Catalog",
                                                     ThreadExtensions.GetDescription(Thread.CurrentThread));
                    throw new TimeoutException(msg);
                }

                if (m_hasLoadedCatalog)
                {
                    return;
                }

                SyntaxLoader.LoadCatalog();

                m_hasLoadedCatalog = true;
            } finally {
                if (gotLock)
                {
                    Monitor.Exit(m_lockForCatalogLoad);
                }
            }
        }
示例#2
0
        private void InitSyntaxDefinition()
        {
            bool gotLock = Monitor.TryEnter(this, TimeSpan.FromSeconds(20));

            if (!gotLock)
            {
                string msg = StringExtensions.Fi("Thread {0} was waiting for the SyntaxDefinition for syntax '{1}' to be built by another thread, " +
                                                 "but after 20 seconds this is still not done. This may be due to excessive load on the computer or because of an Iris bug.",
                                                 ThreadExtensions.GetDescription(Thread.CurrentThread), this.Id);

                throw new TimeoutException(msg);
            }

            try {
                if (this.m_syntaxDefinition != null)
                {
                    return;
                }

                this.m_syntaxDefinition = SyntaxLoader.BuildSyntaxDefinition(this.Id);
            } finally {
                Monitor.Exit(this);
            }
        }