private void Sum(object obj) { result = 0; long num = Convert.ToInt64(obj); UpdateProgressBarDelegate upd = new UpdateProgressBarDelegate(UpdateProgressBar); for (long i = 0; i <= num; i++) { result += i; if (i % 10000 == 0) { if (progressBar1.InvokeRequired) { progressBar1.Invoke(upd, new object[] { progressBar1, Convert.ToInt32((100 * i) / num) }); } else { progressBar1.Value = Convert.ToInt32(i / num * 100); } } } if (lblResult.InvokeRequired) { UpdateLabelDelegate uld = new UpdateLabelDelegate(UpdateLabel); lblResult.Invoke(uld, new object[] { lblResult, result.ToString() }); } }
public Form2(UpdateLabelDelegate method, UpdateLabelDelegateStr method1, UpdateLabelDelegateStrReturn method2, Form1 form1) : this() { this._updateLable = method; this._updateLableStr = method1; this._updateLableStrReturn = method2; this._form1 = form1; }
private void StandardInitialization() { InitializeComponent(); updateMainLabel = new UpdateLabelDelegate(UpdateMainLabel); updateProgressBar = new UpdateProgressBarDelegate(UpdateProgressBar); updateBottomBar = new UpdateLabelDelegate(UpdateBottomBar); uploadFiles = new EmptyDelegate(StartFileUploadThreadSafe); CloseOnComplete = true; formTimer.AutoReset = false; formTimer.Elapsed += formTimer_Elapsed; }
private void UpdateLastLabelSafe(Label lbl, int quantity) { if (lbl.InvokeRequired) { UpdateLabelDelegate uld = new UpdateLabelDelegate(UpdateLastLabelSafe); Invoke(uld, new object[] { lbl, quantity }); } else { lbl.Text += " (" + quantity + " appointments scheduled)"; } }
public void log(string msg) { if (logLabel.InvokeRequired) { var d = new UpdateLabelDelegate(log); logLabel.Invoke(d, new object[] { msg }); } else { logData.Append(msg.Replace("\n", "\r\n") + "\r\n"); logLabel.Text = logData.ToString(); logLabel.Select(logLabel.Text.Length, logLabel.Text.Length); logLabel.ScrollToCaret(); } }
public void UpdateLog(string text) { if (InvokeRequired) { UpdateLabelDelegate del = UpdateLog; object[] param = new object[] { text }; richTextBoxServer.Invoke(del, param); } else { richTextBoxServer.AppendText(text + "\n"); } }
public void Updateclientlist(string text) { if (InvokeRequired) { UpdateLabelDelegate del = Updateclientlist; object[] param = new object[] { text }; richTextBoxClient.Invoke(del, param); } else { richTextBoxClient.AppendText(text + "\n"); } }
private void UpdateLabel(char c, string tName) { //Not on UI thread if (this.lblOutput.InvokeRequired) { Thread.Sleep(150); UpdateLabelDelegate del = new UpdateLabelDelegate(UpdateLabel); this.BeginInvoke(del, new object[] { c, tName }); } else //On UI thread { this.lblThread.Text = tName; this.lblOutput.Text += c; this.lblOutput.Refresh(); } }
void PrintTime() { if (label1.InvokeRequired == true) { UpdateLabelDelegate uld = new UpdateLabelDelegate(UpdateLabel); while (true) { label1.Invoke(uld, new object[] { label1, DateTime.Now.ToString() }); } } else { while (true) { label1.Text = DateTime.Now.ToString(); } } }
private void PrintTime() { if (label1.InvokeRequired.Equals(true)) { UpdateLabelDelegate myDele = new UpdateLabelDelegate(UpdateUi); while (true) { label1.Invoke(myDele, new object[] { label1, DateTime.Now.ToString() }); } } else { while (true) { label1.Text = DateTime.Now.ToString(); } } }
private void Updateclientlist(RichTextBox textboxclient, string text) { if (textboxclient.InvokeRequired) { UpdateLabelDelegate del = Updateclientlist; object[] param = new object[] { textboxclient, text }; textboxclient.Invoke(del, param); } else { if (text == "") { textboxclient.Text = ""; } else { textboxclient.AppendText(text + "\n"); } } }
public Bot2(UpdateLabelDelegate TimeCallback, UpdateLabelDelegate LeftCallback, UpdateLabelDelegate RightCallback, UpdateLabelDelegate ForwardCallback, UpdateLabelDelegate BackCallback, UpdateLabelDelegate ListCallback) { // all the "Update" delegates are callbacks // on the UI thread to update the UI UpdateTimer = TimeCallback; UpdateLeft = LeftCallback; UpdateRight = RightCallback; UpdateForward = ForwardCallback; UpdateBack = BackCallback; UpdateList = ListCallback; //don't do this at home kids, this is an embarassingly bad way to make config files string[] lines = System.IO.File.ReadAllLines(@"d:\dev\TwitchDrivesATV\config.txt"); VEHICLE_API_URL = lines[0]; TWITCH_API_KEY = lines[1]; VoteEndTimer = new System.Threading.Timer(OnTimer, null, 1000, 1000); ConnectionCredentials credentials = new ConnectionCredentials("twitchDrivesATV", TWITCH_API_KEY); var clientOptions = new ClientOptions { MessagesAllowedInPeriod = 750, ThrottlingPeriod = TimeSpan.FromSeconds(30) }; WebSocketClient customClient = new WebSocketClient(clientOptions); client = new TwitchClient(customClient); client.Initialize(credentials, "twitchDrivesATV"); client.OnLog += Client_OnLog; client.OnJoinedChannel += Client_OnJoinedChannel; client.OnMessageReceived += Client_OnMessageReceived; client.OnWhisperReceived += Client_OnWhisperReceived; client.OnNewSubscriber += Client_OnNewSubscriber; client.OnConnected += Client_OnConnected; client.Connect(); }
private void DispatchLabel(string text) { UpdateLabelDelegate uLabelDel = new UpdateLabelDelegate(UpdateLabel); lblStatusBar.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, uLabelDel, text); }
private void RemoveBtnClick(object sender, RoutedEventArgs e) { if (fileStructListView.SelectedItems.Count < 1) { MessageBox.Show("No files selected.", "No Files Selected"); return; } var updatePbDelegate = new UpdateProgressBarDelegate(progressBar1.SetValue); var updateCurFile = new UpdateLabelDelegate(curFileLabel.SetValue); double value = 0; progressBar1.Minimum = 0; progressBar1.Maximum = fileStructListView.SelectedItems.Count; progressBar1.Value = 0; foreach (fileStruct file in fileStructListView.SelectedItems) { if (_stop) { ClearVars(); _stop = false; break; } Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value }); var progressMessage = "Deleting: " + file.fullPath; Dispatcher.Invoke(updateCurFile, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBox.TextProperty, progressMessage }); _removeFiles.removeFiles(file, _permanentDelete); } selectOldestBtn.IsEnabled = false; selectNewestBtn.IsEnabled = false; curFileLabel.Text = ""; ClearVars(); }
private void FindFilesClick(object sender, RoutedEventArgs e) { ClearVars(); stopBtn.IsEnabled = true; clearBtn.IsEnabled = false; if(!Directory.Exists(searchDir.Text)){ var msg = "Directory " + searchDir.Text + " does not exists."; MessageBox.Show(msg, "No Such Directory"); return; } if(string.IsNullOrEmpty(searchPattern.Text)) searchPattern.Text = "*"; var di = new DirectoryInfo(searchDir.Text); var files = di.GetFiles(searchPattern.Text, _dirChoice); double value = 0; progressBar1.Minimum = 0; progressBar1.Maximum = files.Length; progressBar1.Value = 0; var updatePbDelegate = new UpdateProgressBarDelegate(progressBar1.SetValue); var updateCurFile = new UpdateLabelDelegate(curFileLabel.SetValue); foreach (var file in files) { if (_stop) { _stop = false; break; } value += 1; Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value }); var progressMessage = "Scanning: " + file.FullName; Dispatcher.Invoke(updateCurFile, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBox.TextProperty, progressMessage }); var md5 = ""; if (!_nameOnly) { var findHash = new findMD5(); md5 = findHash.getFilesMD5Hash(file.FullName); } var fStruct = new fileStruct{ checksum = md5, fileName = file.Name, fullPath = file.FullName, creationDate=file.CreationTime }; _listOfFiles.Add(fStruct); } curFileLabel.Text = ""; ArrayList duplicates = new ArrayList(); if (_nameOnly) { _listOfFiles.Sort(_compareByFileName); duplicates = _duplicateFiles.findDuplicatesByFileName(_listOfFiles); } else { _listOfFiles.Sort(_compareByCheckSum); duplicates = _duplicateFiles.findDuplicatesByCheckSum(_listOfFiles); } foreach(fileStruct file in duplicates){ fileStructListView.Items.Add(file); } stopBtn.IsEnabled = false; clearBtn.IsEnabled = true; selectOldestBtn.IsEnabled = true; selectNewestBtn.IsEnabled = true; progressBar1.Value = 0; }
/// <summary> /// Handles A batch save /// </summary> public void HandleBatchSave(string directory, string baseName, string saveType, bool useScansInGrid, bool usePeptideAndScanName, bool addDatasetName, UpdateLabelDelegate updateLabelCallback, ref bool cancelSearch) { updateLabelCallback("Starting Batch Save..."); m_batchSaveCounter = 0; foreach (ResultRowData row in m_dataView.GetPeptidesAndScansInGrid(useScansInGrid)) { if (!cancelSearch) { string nextFilebase = baseName; if (!string.IsNullOrWhiteSpace(row.DatasetName)) { DataFileName = row.DatasetName; if (addDatasetName) { nextFilebase += "_" + Path.GetFileNameWithoutExtension(row.DatasetName); } } PrecursorMZ = row.DblPrecursorMZ; string nextFileName = createNextFileName(nextFilebase, usePeptideAndScanName, row.Peptide, row.ScanNumber) + saveType; updateLabelCallback("Saving \"" + nextFileName + "\""); this.HandleSelectScanAndPeptide(row.ScanNumber, row.Peptide); m_plot.SavePlotImageAs(Path.Combine(directory, nextFileName)); } } updateLabelCallback("Finished Batch Save"); }