private void BgCleaner_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { sWebhook.Token = TbxToken.Text.Trim(); sWebhook.UriClean = TbxUri.Text.Trim(); sWebhook.UriCurrent = TbxUriDefault.Text.Trim(); if (!string.IsNullOrEmpty(sWebhook.Token) && !string.IsNullOrEmpty(sWebhook.UriClean)) { int count = sWebhook.GetWebhookInfo().PendingUpdateCount; tsProgBar.GetCurrentParent().Invoke((MethodInvoker) delegate { tsProgBar.Maximum = count; }); for (int x = 0; x <= count; count--) { sWebhook.HapusWebhook(); sWebhook.GetUpdates(); sWebhook.SetWebhook(); count = sWebhook.GetWebhookInfo().PendingUpdateCount; e.Result = count; tsProgBar.GetCurrentParent().Invoke((MethodInvoker) delegate { tsProgBar.Value = tsProgBar.Maximum - count; }); //HControls.InvokeIfRequired(this, LblResult => LblResult.Text = "Sisa pendings : " + count); LblResult.Invoke((MethodInvoker) delegate { LblResult.Text = "Sisa pending : " + count; }); } if (!string.IsNullOrEmpty(sWebhook.UriCurrent) && SetURIHookSetBersihkanToolStripMenuItem.Checked) { sWebhook.SetWebhookDefault(); } if (!BwChecker.IsBusy) { BwChecker.RunWorkerAsync(); } } else { MessageBox.Show("Token & URI Clear Hook dibutuhkan!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BwChecker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { sWebhook.Token = TbxToken.Text.Trim(); sWebhook.UriClean = TbxUri.Text.Trim(); sWebhook.UriCurrent = TbxUriDefault.Text.Trim(); if (!string.IsNullOrEmpty(sWebhook.Token)) { var data = sWebhook.GetWebhookInfo(); LblResult.Invoke((MethodInvoker) delegate { LblResult.Text = "URI Webhook : " + data.Url + "\nPending Update : " + data.PendingUpdateCount + "\nMax Connection : " + data.MaxConnections + "\nLast Error Date : " + data.LastErrorDate + "\nLast Error Message : " + data.LastErrorMessage; }); if (data.PendingUpdateCount > 5) { LblResult.Invoke((MethodInvoker) delegate { LblResult.Text += "\nLebih dari " + data.PendingUpdateCount; }); if (bersihkanPendingCountOtomatisToolStripMenuItem.Checked) { BgCleaner.RunWorkerAsync(); } //PushNotif("Pending Update Count : " + data.PendingUpdateCount); } } else { MessageBox.Show("Token dibutuhkan!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }