Esempio n. 1
0
        private static void OnAbort()
        {
            ExportQueue.Clear();

            if (ExportThread != null)
            {
                if (ExportThread.IsAlive || ExportThread.ThreadState == ThreadState.Running)
                {
                    ExportThread.Abort();
                    ExportThread.Join(3000);
                }

                ExportThread = null;
            }

            if (_Connection != null && _Connection.Connected)
            {
                _Connection.Close();
                _Connection = null;
            }

            CMOptions.ToConsole("Update aborted.");

            _Updating = false;
        }
Esempio n. 2
0
        private static void Cancel()
        {
            if (!_Updating)
            {
                ExportQueue.Clear();
                return;
            }

            if (ExportThread != null)
            {
                if (ExportThread.IsAlive || ExportThread.ThreadState == ThreadState.Running)
                {
                    ExportThread.Abort();
                    ExportThread.Join(3000);
                }

                ExportThread = null;
            }

            if (_Connection != null)
            {
                _Connection.Close();
                _Connection = null;
            }

            _Updating = false;
        }
Esempio n. 3
0
        private static void UpdateCallback()
        {
            if (_Updating || !Connection.Connected)
            {
                return;
            }

            _Updating = true;

            LastUpdate = DateTime.Now;

            Connection.NonQuery(
                @"CREATE DATABASE IF NOT EXISTS `{0}` DEFAULT CHARSET `utf8` DEFAULT COLLATE `utf8_bin`",
                CMOptions.MySQL.Database);

            Connection.UseDatabase(CMOptions.MySQL.Database);

            var watch = new Stopwatch();

            watch.Start();

            VitaNexCore.TryCatch(
                () =>
            {
                Process();
                Flush();
            },
                x =>
            {
                CMOptions.ToConsole(x);
                OnAbort();
            });

            watch.Stop();

            CMOptions.ToConsole("Updated {0:#,0} objects in {1:F2} seconds.", _UpdateCount, watch.Elapsed.TotalSeconds);

            if (UpdateTimes.Count >= 10)
            {
                UpdateTimes.Dequeue();
            }

            UpdateTimes.Enqueue(watch.Elapsed);

            ExportQueue.Clear();

            if (_Connection != null)
            {
                _Connection.Close();
                _Connection = null;
            }

            //GC.Collect();

            _UpdateCount = 0;
            _Updating    = false;
        }