Exemplo n.º 1
0
        void UpdateStatusBarWorker(Action done)
        {
            SetSearchKeywords();

            var start              = DateTime.Now.Millisecond;
            int filteredListCount  = GetFilteredList().Count;
            int allServersCount    = servers.CountAllServers();
            int serverControlCount = GetAllServerControls().Count();

            // may cause dead lock in UI thread
            int selectedServersCount = servers.CountSelectedServers();

            Action worker = () =>
            {
                UpdateStatusBarText(filteredListCount, allServersCount, selectedServersCount, serverControlCount);
                UpdateStatusBarPageSelectorMenuItemsOndemand();
                UpdateStatusBarPagingButtons();

                // prevent formain lost focus after click next page
                if (isFocusOnFormMain)
                {
                    formMain.Focus();
                    isFocusOnFormMain = false;
                }
            };

            Action next = () =>
            {
                var relex = statusBarUpdateInterval - (DateTime.Now.Millisecond - start);
                VgcApis.Misc.Utils.Sleep(Math.Max(0, relex));
                done();
            };

            VgcApis.Misc.UI.InvokeThen(worker, next);
        }
Exemplo n.º 2
0
        void UpdateStatusBarNow()
        {
            int filteredListCount    = GetFilteredList().Count;
            int allServersCount      = servers.CountAllServers();
            int selectedServersCount = servers.CountSelectedServers(); // may cause dead lock in UI thread
            int serverControlCount   = GetAllServerControls().Count();

            VgcApis.Misc.UI.RunInUiThreadIgnoreError(formMain, () =>
            {
                UpdateStatusBarText(
                    filteredListCount,
                    allServersCount,
                    selectedServersCount,
                    serverControlCount);

                UpdateStatusBarPageSelectorMenuItemsOndemand();
                UpdateStatusBarPagingButtons();

                // prevent formain lost focus after click next page
                if (isFocusOnFormMain)
                {
                    formMain.Focus();
                    isFocusOnFormMain = false;
                }
            });

            HighLightSearchKeywordsNow();
        }