private void LuaUI_Load(object sender, EventArgs e) { lazyUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateUiWorker, 300, 2000) { Name = "Luna.UiPanelUpdater", }; }
private void FormQRCode_Shown(object sender, EventArgs e) { ClearServerList(); cboxLinkType.SelectedIndex = LinkTypeToComboBoxSelectedIndex(linkType); picQRCode.InitialImage = null; SetPicZoomMode(); this.FormClosed += (s, a) => { ReleaseServerEvents(); servListUpdater?.ForgetIt(); servListUpdater?.Quit(); }; servListUpdater = new VgcApis.Libs.Tasks.LazyGuy( () => { try { VgcApis.Libs.Utils.RunInBackground(RefreshServerList); } catch { } }, VgcApis.Models.Consts.Intervals.FormQrcodeMenuUpdateDelay); BindServerEvents(); servListUpdater.DoItLater(); }
private void FormQRCode_Load(object sender, EventArgs e) { ClearServerList(); cboxLinkType.SelectedIndex = LinkTypeToComboBoxSelectedIndex(linkType); picQRCode.InitialImage = null; SetPicZoomMode(); this.FormClosed += (s, a) => { ReleaseServerEvents(); lazyServerListUpdater?.Dispose(); }; lazyServerListUpdater = new VgcApis.Libs.Tasks.LazyGuy( RefreshServerListWorker, VgcApis.Models.Consts.Intervals.FormQrcodeMenuUpdateDelay, 1000) { Name = "Qrcode.RefreshServerListWorker()", }; BindServerEvents(); lazyServerListUpdater.Postpone(); }
public Subscription( FlowLayoutPanel flyPanel, Button btnAdd, Button btnUpdate, CheckBox chkSubsIsUseProxy, CheckBox chkSubsIsAutoPatch, Button btnUseAll, Button btnInvertSelection) { this.setting = Services.Settings.Instance; this.servers = Services.Servers.Instance; this.slinkMgr = Services.ShareLinkMgr.Instance; this.flyPanel = flyPanel; this.btnAdd = btnAdd; this.btnUpdate = btnUpdate; this.chkSubsIsUseProxy = chkSubsIsUseProxy; this.chkSubsIsAutoPatch = chkSubsIsAutoPatch; this.btnUseAll = btnUseAll; this.btnInvertSelection = btnInvertSelection; chkSubsIsUseProxy.Checked = setting.isUpdateUseProxy; lazyCounter = new VgcApis.Libs.Tasks.LazyGuy(UpdateServUiTotalWorker, 500, 5000) { Name = "SubsCtrl.CountTotal()", }; InitPanel(); BindEvent(); MarkDuplicatedSubsInfo(); lazyCounter?.Postpone(); }
public void LazyGuyTest() { var str = ""; void task() { str += "."; } var adam = new VgcApis.Libs.Tasks.LazyGuy(task, 100); adam.DoItNow(); Assert.AreEqual(".", str); str = ""; adam.DoItLater(); adam.ForgetIt(); Assert.AreEqual("", str); #if DEBUG str = ""; adam.DoItLater(); adam.DoItLater(); adam.DoItLater(); Thread.Sleep(1000); Assert.AreEqual(".", str); str = ""; adam.DoItLater(); Thread.Sleep(300); Assert.AreEqual(".", str); #endif }
private void ServerUI_Load(object sender, EventArgs e) { UpdateOnOffLabel(false); roundLables = new List <Control> { rlbTotalNetFlow, rlbMark, rlbRemark, rlbSpeedtest, }; rtboxServerTitle.BackColor = BackColor; rlbSpeedtest.Text = @""; rlbSpeedtest.Visible = false; lazyUiUpdater = new VgcApis.Libs.Tasks.LazyGuy(RefreshUiWorker, 250, 3000) { Name = "ServerUi.RefreshPanel", }; lazyHighlighter = new VgcApis.Libs.Tasks.LazyGuy( HighLightKeywordsThen, 400, 1000) { Name = "ServerUi.HighLight", }; InitButtonBackgroundImage(); BindCoreCtrlEvents(); RefreshUiLater(); }
public MenuUpdater( Views.WinForms.FormConfiger formConfiger, ToolStripMenuItem miReplaceServer, ToolStripMenuItem miLoadServer) { servers = Services.Servers.Instance; this.formConfiger = formConfiger; this.miReplaceServer = miReplaceServer; this.miLoadServer = miLoadServer; menuUpdater = new VgcApis.Libs.Tasks.LazyGuy( () => { try { VgcApis.Misc.Utils.RunInBackground( UpdateServerMenus); } catch { // Do not hurt me. } }, VgcApis.Models.Consts.Intervals.FormConfigerMenuUpdateDelay); }
public FlyServer( Form formMain, FlowLayoutPanel panel, ToolStripLabel lbMarkFilter, ToolStripComboBox cboxMarkeFilter, ToolStripStatusLabel tslbTotal, ToolStripDropDownButton tsdbtnPager, ToolStripStatusLabel tslbPrePage, ToolStripStatusLabel tslbNextPage, ToolStripMenuItem miResizeFormMain) { servers = Services.Servers.Instance; setting = Services.Settings.Instance; this.formMain = formMain; this.flyPanel = panel; this.cboxMarkFilter = cboxMarkeFilter; this.tsdbtnPager = tsdbtnPager; this.tslbTotal = tslbTotal; this.tslbPrePage = tslbPrePage; this.tslbNextPage = tslbNextPage; this.welcomeItem = new Views.UserControls.WelcomeUI(); lazyStatusBarUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateStatusBarNow, 300); lazySearchResultDisplayer = new VgcApis.Libs.Tasks.LazyGuy(ShowSearchResultNow, 1000); lazyUiRefresher = new VgcApis.Libs.Tasks.LazyGuy(() => RefreshUI(), 300); InitFormControls(lbMarkFilter, miResizeFormMain); BindDragDropEvent(); RefreshUI(); WatchServers(); }
Servers() { lazyServerSettingsRecorder = new VgcApis.Libs.Tasks.LazyGuy( SaveServersSettingsWorker, VgcApis.Models.Consts.Intervals.LazySaveServerListIntreval, 1000) { Name = "Servers.SaveSettings()", }; }
private void FormDataGrid_Load(object sender, EventArgs e) { InitControls(); lazyUiUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateUiWorker, UPDATE_INTERVAL, 1500) { Name = "Luna.DataGridUpdater", }; UpdateUiWorker(); dgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; }
private void LuaUI_Load(object sender, EventArgs e) { luaCoreCtrl.OnStateChange += OnLuaCoreStateChangeHandler; lazyUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateUiWorker, 300, 2000) { Name = "Luna.UiPanelUpdater", }; UpdateUiLater(); }
Notifier() { notifierUpdater = new VgcApis.Libs.Tasks.LazyGuy( UpdateNotifyIconNow, VgcApis.Models.Consts.Intervals.NotifierTextUpdateIntreval); serversMenuUpdater = new VgcApis.Libs.Tasks.LazyGuy( UpdateServersMenu, VgcApis.Models.Consts.Intervals.NotifierTextUpdateIntreval); }
public void Run(Settings settings) { this.settings = settings; lazyAnalyser = new VgcApis.Libs.Tasks.LazyGuy(AnalizeScriptWorker, 1000, 3000); InitControls(settings); BindEvents(); SetIsEnableCodeAnalyze(false); UpdateLuaRequireModuleNameSnippets(); }
public LinkImporter( Setting setting, Servers servers, ConfigMgr configMgr, VgcApis.Libs.Tasks.LazyGuy serverSaver) { this.serverSaver = serverSaver; this.setting = setting; this.servers = servers; this.configMgr = configMgr; }
public ServerUI(VgcApis.Interfaces.ICoreServCtrl serverItem) { servers = Services.Servers.Instance; slinkMgr = Services.ShareLinkMgr.Instance; settings = Services.Settings.Instance; this.coreServCtrl = serverItem; InitializeComponent(); lazyUiUpdater = new VgcApis.Libs.Tasks.LazyGuy(RefreshUiLater, 100); }
public void Run( VgcApis.Models.IServices.ISettingsService vgcSetting) { this.vgcSetting = vgcSetting; userSettings = VgcApis.Libs.Utils .LoadPluginSetting <Models.Data.UserSettings>( pluginName, vgcSetting); bookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSettingsNow, 30000); }
public void Run( VgcApis.Models.IServices.ISettingsService vgcSetting, VgcApis.Models.IServices.IServersService vgcServers) { this.vgcSetting = vgcSetting; this.vgcServers = vgcServers; userSettins = LoadUserSetting(); bookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSetting, VgcApis.Models.Consts.Intervals.LazySaveStatisticsDatadelay); StartBgStatsDataUpdateTimer(); vgcServers.OnCoreClosing += OnCoreClosingHandler; }
public void Run( LuaServer luaServer, ToolStripMenuItem miRoot, ToolStripMenuItem miShowWindow) { this.luaServer = luaServer; this.miRoot = miRoot; this.miShowWindow = miShowWindow; lazyMenuUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateMenuLater, 1000); BindEvents(); UpdateMenuLater(); }
public FlyServer( Form formMain, FlowLayoutPanel panel, ToolStripLabel lbMarkFilter, ToolStripComboBox cboxMarkeFilter, ToolStripStatusLabel tslbTotal, ToolStripDropDownButton tsdbtnPager, ToolStripStatusLabel tslbPrePage, ToolStripStatusLabel tslbNextPage, ToolStripMenuItem miResizeFormMain) { servers = Services.Servers.Instance; setting = Services.Settings.Instance; this.formMain = formMain; this.flyPanel = panel; this.cboxMarkFilter = cboxMarkeFilter; this.tsdbtnPager = tsdbtnPager; this.tslbTotal = tslbTotal; this.tslbPrePage = tslbPrePage; this.tslbNextPage = tslbNextPage; this.welcomeItem = new Views.UserControls.WelcomeUI(); lazyFlyPanelUpdater = new VgcApis.Libs.Tasks.LazyGuy( RefreshFlyPanelWorker, flyPanelUpdateInterval, 2000) { Name = "FormMain.RefreshFlyPanelWorker()", }; lazyStatusBarUpdater = new VgcApis.Libs.Tasks.LazyGuy( UpdateStatusBarWorker, statusBarUpdateInterval, 3000) { Name = "FormMain.UpdateStatusBarWorker()", // disable debug logging }; lazySearchResultDisplayer = new VgcApis.Libs.Tasks.LazyGuy( ShowSearchResultNow, 1300, 1000) { Name = "FormMain.ShowSearchResultNow()", }; InitFormControls(lbMarkFilter, miResizeFormMain); BindDragDropEvent(); RefreshFlyPanelLater(); WatchServers(); }
public void Run( VgcApis.Models.IServices.ISettingsService vgcSetting) { this.vgcSetting = vgcSetting; this.luaAcm = new Libs.LuaSnippet.LuaAcm(); userSettings = VgcApis.Libs.Utils .LoadPluginSetting <Models.Data.UserSettings>( pluginName, vgcSetting); userSettings.NormalizeData(); bookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSettingsNow, 30000); bookKeeper.DoItLater(); }
public SubscriptionUI( Subscription subsCtrl, Models.Datas.SubscriptionItem subscriptItem) { InitializeComponent(); this.subsCtrl = subsCtrl; servers = Services.Servers.Instance; lazyCounter = new VgcApis.Libs.Tasks.LazyGuy(UpdateServerTotalNow, 1000); // tab page is lazy, do not call this in Load(). InitControls(subscriptItem); BindEvent(); lazyCounter.DoItLater(); Disposed += (s, a) => Cleanup(); }
public void Run( VgcApis.Interfaces.Services.ISettingsService vgcSetting, VgcApis.Interfaces.Services.IServersService vgcServers) { this.vgcSetting = vgcSetting; this.vgcServers = vgcServers; userSettins = LoadUserSetting(); bookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSetting, VgcApis.Models.Consts.Intervals.LazySaveStatisticsDatadelay, 500) { Name = "Statistic.SaveUserSetting", }; StartBgStatsDataUpdateTimer(); vgcServers.OnCoreClosing += SaveStatDataBeforeCoreClosed; }
public MenuUpdater( Views.WinForms.FormConfiger formConfiger, ToolStripMenuItem miReplaceServer, ToolStripMenuItem miLoadServer) { servers = Services.Servers.Instance; this.formConfiger = formConfiger; this.miReplaceServer = miReplaceServer; this.miLoadServer = miLoadServer; lazyServerMenuItemsUpdater = new VgcApis.Libs.Tasks.LazyGuy( ServerMenuItemsUpdateWorker, VgcApis.Models.Consts.Intervals.FormConfigerMenuUpdateDelay, 1500) { Name = "Vgc.Configer.MenuUpdater", }; }
public void Run( Settings setting, Servers servers, ShareLinkMgr shareLinkMgr, Updater updater) { this.setting = setting; this.servers = servers; this.slinkMgr = shareLinkMgr; this.updater = updater; lazyNotifierMenuUpdater = new VgcApis.Libs.Tasks.LazyGuy( UpdateNotifyIconWorker, UpdateInterval, 5000) { Name = "Notifier.MenuUpdater", // disable debug logging }; BindNiMenuEvents(ni); BindServerEvents(); RefreshNotifyIconLater(); }
public void Run( LuaServer luaServer, ToolStripMenuItem miRoot, ToolStripMenuItem miShowMgr, ToolStripMenuItem miShowEditor) { this.luaServer = luaServer; this.miRoot = miRoot; this.miShowMgr = miShowMgr; this.miShowEditor = miShowEditor; lazyMenuUpdater = new VgcApis.Libs.Tasks.LazyGuy(UpdateMenuWorker, 500, 3000) { Name = "Luna.MenuUpdater", }; BindEvents(); UpdateMenuLater(); }
public ServerUI() { servers = Services.Servers.Instance; slinkMgr = Services.ShareLinkMgr.Instance; settings = Services.Settings.Instance; InitializeComponent(); roundLables = new List <Control> { rlbSetting, rlbInboundMode, rlbLastModifyDate, rlbRemark, rlbTotalNetFlow, rlbMark, rlbSpeedtest, }; lazyUiUpdater = new VgcApis.Libs.Tasks.LazyGuy(RefreshUiWorker, 400, 3000) { Name = "ServerUi.RefreshPanel", }; lazyHighlighter = new VgcApis.Libs.Tasks.LazyGuy( HighLightKeywordsThen, 400, 1000) { Name = "ServerUi.HighLight", }; InitButtonBackgroundImage(); ResetControls(); foreach (Control item in this.Controls) { item.MouseEnter += ShowCtrlBtn; } }
// Singleton need this private ctor. Settings() { userSettings = LoadUserSettings(); userSettings.Normalized(); // replace null with empty object. UpdateSpeedTestPool(); UpdateFileLoggerSetting(); janitor = new VgcApis.Libs.Tasks.LazyGuy( () => GC.Collect(), VgcApis.Models.Consts.Intervals.LazyGcDelay, 5000) { Name = "Settings.GC()", }; lazyBookKeeper = new VgcApis.Libs.Tasks.LazyGuy( SaveUserSettingsWorker, VgcApis.Models.Consts.Intervals.LazySaveUserSettingsDelay, 500) { Name = "Settings.SaveSettings", }; }
public void LazyGuyChainedTaskTest() { var str = ""; Action <Action> secTask = (done) => { Task.Delay(200).Wait(); str += "2"; done(); }; Action <Action> firstTask = (done) => { Task.Delay(200).Wait(); str += "1"; secTask(done); }; var alex = new VgcApis.Libs.Tasks.LazyGuy(firstTask, 1000, 300); str = ""; alex.Deadline(); alex.Throttle(); alex.Deadline(); alex.Throttle(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("12", str); str = ""; alex.Postpone(); alex.Deadline(); alex.Postpone(); alex.Throttle(); Task.Delay(500).Wait(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("12", str); str = ""; alex.Postpone(); Task.Delay(500).Wait(); alex.Postpone(); Task.Delay(500).Wait(); alex.Postpone(); Task.Delay(500).Wait(); alex.Postpone(); Task.Delay(500).Wait(); alex.Postpone(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("12", str); str = ""; alex.Deadline(); alex.Deadline(); alex.Deadline(); Assert.AreEqual("", str); Task.Delay(5000).Wait(); Assert.AreEqual("12", str); str = ""; alex.Deadline(); alex.Deadline(); alex.Deadline(); alex.ForgetIt(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("", str); alex.PickItUp(); str = ""; alex.Throttle(); alex.Throttle(); alex.Throttle(); alex.ForgetIt(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("", str); alex.PickItUp(); str = ""; alex.Throttle(); Task.Delay(100).Wait(); alex.Throttle(); alex.Throttle(); Assert.AreEqual("", str); Task.Delay(5000).Wait(); Assert.AreEqual("1212", str); }
Servers() { serverSaver = new VgcApis.Libs.Tasks.LazyGuy( SaveServersSettingsNow, VgcApis.Models.Consts.Intervals.LazySaveServerListIntreval); }
public void LazyGuySingleTaskTest() { var str = ""; void task() { Task.Delay(200).Wait(); str += "."; } var adam = new VgcApis.Libs.Tasks.LazyGuy(task, 1000, 300); str = ""; adam.Postpone(); Task.Delay(500).Wait(); Console.WriteLine("500 x 1"); adam.Postpone(); Task.Delay(500).Wait(); Console.WriteLine("500 x 2"); adam.Postpone(); Task.Delay(500).Wait(); Console.WriteLine("500 x 3"); adam.Postpone(); Task.Delay(500).Wait(); Console.WriteLine("500 x 4"); adam.Postpone(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual(".", str); str = ""; adam.Deadline(); Task.Delay(10).Wait(); adam.Deadline(); Task.Delay(10).Wait(); adam.Deadline(); Task.Delay(10).Wait(); adam.Deadline(); Task.Delay(10).Wait(); adam.Deadline(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual(".", str); str = ""; adam.Deadline(); Task.Delay(3000).Wait(); Assert.AreEqual(".", str); str = ""; adam.Deadline(); adam.ForgetIt(); Task.Delay(3000).Wait(); Assert.AreEqual("", str); adam.PickItUp(); str = ""; adam.Throttle(); adam.ForgetIt(); Task.Delay(1000).Wait(); Assert.AreEqual("", str); adam.PickItUp(); str = ""; adam.Throttle(); Task.Delay(50).Wait(); // wait for task spin up adam.Throttle(); adam.Throttle(); adam.Throttle(); adam.Throttle(); Assert.AreEqual("", str); Task.Delay(3000).Wait(); Assert.AreEqual("..", str); str = ""; adam.Throttle(); Task.Delay(1000).Wait(); Assert.AreEqual(".", str); }