Пример #1
0
        /// <summary>
        /// Commands the executer.
        /// </summary>
        private void CommandExecuter()
        {
            while (true)
            {
                if (commandsQueue.Count <= 0)
                {
                    Thread.CurrentThread.IsBackground = true;
                }
                while (commandsQueue.Count <= 0)
                {
                    Thread.Sleep(10);
                }

                Thread.CurrentThread.IsBackground = false;
                SqlCE.ExecuteNonQuery(commandsQueue.Dequeue());
            }
        }
Пример #2
0
        /// <summary>
        /// Executes the command async.
        /// </summary>
        /// <param name="command">The command.</param>
        private void ExecuteCommandAsync(SqlCeCommand command)
        {
            if (CACHE_ENABLED)
            {
                if (asyncThread == null)
                {
                    asyncThread                  = new Thread(new ThreadStart(CommandExecuter));
                    asyncThread.Priority         = ThreadPriority.Lowest;
                    asyncThread.Name             = "SqlCE Command Execution Thread";
                    asyncThread.CurrentCulture   = Thread.CurrentThread.CurrentCulture;
                    asyncThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
                    asyncThread.Start();
                }

                commandsQueue.Enqueue(command);
                asyncThread.IsBackground = false;
            }
            else
            {
                SqlCE.ExecuteNonQuery(command);
            }
        }