Example #1
0
        /// <summary>
        /// Function to close the data store for writing.
        /// </summary>
        /// <param name="closingMessage">[Optional] The message to write when closing.</param>
        public void Close(string closingMessage = null)
        {
            if (Interlocked.Exchange(ref _hasConsole, 0) == 0)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(closingMessage))
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(closingMessage);
            }

            Console.ResetColor();

            if (!_ownsConsole)
            {
                return;
            }

            Debug.Assert(KernelApi.FreeConsole() != 0);
            _ownsConsole = false;
        }