private void button_Export_Click(object sender, EventArgs e) { if (ActDebit == null) { MessageBox.Show("Что-то пошло не так и акта списания нет..."); return; } if (debitEquipments.Count < 1) { MessageBox.Show("Нет строк в акте списания. Отказ в экспорте..."); return; } SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "Документ Word (*.docx)|*.docx", RestoreDirectory = true }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { button_Export.Enabled = false; ExportDoc(saveFileDialog.FileName); officeExport = new OfficeExport(exportData); officeExport.ReplaceText(); BGWorker.RunWorkerAsync(); } }
private void BTN_Build_Click(object sender, EventArgs e) { GitDepsPath = Path.Combine(TB_Engine.Text, GitDepsRelativePath); CachePath = TB_Cache.Text; TargetPath = TB_Target.Text; if (!Directory.Exists(TB_Engine.Text) || !File.Exists(GitDepsPath)) { MessageBox.Show(@"Invalid Engine Path!"); return; } if (!Directory.Exists(CachePath)) { MessageBox.Show(@"Invalid Cache Path!"); return; } if (!Directory.Exists(TargetPath)) { Directory.CreateDirectory(TargetPath); if (!Directory.Exists(TargetPath)) { MessageBox.Show(@"Invalid Target Path!"); return; } } BGWorker.RunWorkerAsync(); LB_Log.Text = @"Working..."; }
public override void MainLoop() { foreach (BackgroundWorker BGWorker in PCExeSysLink.BGWorkersList) { if (BGWorker == PCExeSysLink.ExtAppBGWorkerLink) { if (BGWorker.IsBusy) { } else { if (!DisableExtAppBGWorker) { BGWorker.RunWorkerAsync(); } } } else if (BGWorker == PCExeSysLink.CommThreadBGWorkerLink) { if (BGWorker.IsBusy) { } else { if (!DisableCommsBGWorker) { BGWorker.RunWorkerAsync(); } } } } }
public CBForm(ExecutorFunc worker) { Text = "Hybmesh operation"; cancel.Anchor = lab1.Anchor = lab2.Anchor = 0; lab1.TextAlign = lab2.TextAlign = ContentAlignment.MiddleCenter; lab1.Width = lab2.Width = pb1.Width = pb2.Width = 400; pb1.Maximum = pb2.Maximum = 100; pb2.MarqueeAnimationSpeed = 100; cancel.Text = "Cancel"; cancel.Click += OnCancel; layout.AutoSize = true; layout.ColumnCount = 1; layout.RowCount = 5; layout.Controls.Add(lab1, 0, 0); layout.Controls.Add(pb1, 0, 1); layout.Controls.Add(lab2, 0, 2); layout.Controls.Add(pb2, 0, 3); layout.Controls.Add(cancel, 0, 4); layout.Dock = System.Windows.Forms.DockStyle.Fill; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; Controls.Add(layout); FormBorderStyle = FormBorderStyle.FixedDialog; CenterToScreen(); bg = new BGWorker(worker, this); bg.RunWorkerAsync(); //Start operation in background }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { Logger.LogData("PROCESSING STARTED", true); //BGWorker.ReportProgress(20, "Downloading info..."); WebClient w = new WebClient(); Logger.LogData("Downloading HTML from " + string.Format(URLFormat, elementString)); try { SourceCode = w.DownloadString(string.Format(URLFormat, elementString)); BGWorker.ReportProgress(100, "Ready"); Logger.LogData("Download Succeded"); //SourceCode = File.ReadAllText(@"C:\Users\Antônio\documents\visual studio 2015\Projects\Scrapper\Scrapper\Resources\bi.html"); } catch (Exception x) { MessageBox.Show("An Error Ocurred :[\n\n\n\nDetails: " + x.Message, "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Stop); BGWorker.ReportProgress(0, "Error: " + x.Message.Substring(0, x.Message.Length / 2) + "..."); Logger.LogData("Download falied, error: " + x.Message); } }
public void Save_image(List <string> urls, string save_path) { int i = 0; foreach (string _url in urls) { string url = _url.Replace("c/240x480/img-master", "img-original"); url = url.Replace("_master1200", ""); url = url.Replace(".jpg", ".png"); string image_path = $"{save_path}\\{Get_pixiv_id(url)}"; try { DownloadFile(url, image_path + ".png"); SetText(Get_pixiv_id(url) + "\r\n"); } catch (Exception e) { if (e.Message == "远程服务器返回错误: (404) 未找到。") { SetText($"{e.Message }{ Get_pixiv_id(url)},使用.JPG尝试\r\n"); url = url.Replace(".png", ".jpg"); DownloadFile(url, image_path + ".jpg"); SetText(Get_pixiv_id(url) + "\r\n"); } else { throw e; } } i++; BGWorker.ReportProgress(i * 100 / urls.Count, urls.Count); } }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { // constantly check if the process is available and open ProcOpen = m.OpenProcess("supertux2"); Thread.Sleep(100); BGWorker.ReportProgress(0); // do UI thread stuff }
private void button1_Click(object sender, EventArgs e) { if (BGWorker.IsBusy) { BGWorker.CancelAsync(); } Application.Exit(); }
/* Ассинхронный экспорт через BGWorker */ private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { while (officeExport.HasNextRow) { int percentage = officeExport.CurrentRow * 100 / officeExport.NumberRows; officeExport.AddRowToTable(); BGWorker.ReportProgress(percentage); } }
private void Button_BGW_Click(object sender, EventArgs e) { if (BGWorker.IsBusy) { return; } this.Button_images.Enabled = false; BGWorker.RunWorkerAsync(); }
private void btnStart_Click(object sender, EventArgs e) { BGWorker.RunWorkerAsync(); //Disable these so the user cannot change the settings while it is watermarking cbSaveFormat.Enabled = false; cbGenerateSmall.Enabled = false; txtWidth.Enabled = false; txtHeight.Enabled = false; }
private async void BGWorker_DoWork(object sender, DoWorkEventArgs e) { ProcOpen = m.OpenProcess("Minecraft.Windows.exe"); if (!ProcOpen) { return; } Thread.Sleep(75); BGWorker.ReportProgress(0); }
private void ParseCommandLineArgs(IList <string> args) { Parser.Default.ParseArguments <Options>(args) .WithParsed(o => { WorkingDirectory = o.WorkingDirectory; Action = o.Action; }); BGWorker.RunWorkerAsync(); }
public Main() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; Lessons = new List <Lesson>(); Manager = new Database.General(); ZoomEntities = new ZoomEntities(); BGWorker = new BGWorker(ref backgroundWorker1); Cfg = new ConfigManagement(); }
private void Form1_Load(object sender, EventArgs e) { if (!Directory.Exists(Directory.GetCurrentDirectory() + "/Scripts")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/Scripts"); } refresh(); LineNumberTextBox.Font = richTextBox1.Font; richTextBox1.Select(); AddLineNumbers(); BGWorker.RunWorkerAsync(); }
private void RSearch_Click(object sender, EventArgs e) { this.elementString = AgilityParser.GetElement(new Random().Next(1, 118)); this.TBSearch.Text = elementString.Replace(elementString[0].ToString(), elementString[0].ToString().ToUpper()); this.NameCB.Checked = true; this.numberCB.Checked = false; if (!BGWorker.IsBusy) { BGWorker.RunWorkerAsync(); } }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; bool running; while (!worker.CancellationPending) { running = m.OpenProcess("HorizonZeroDawn.exe"); BGWorker.ReportProgress(0, running); Thread.Sleep(1000); } }
// Start Operation private void button2_Click(object sender, EventArgs e) { if (Directory.Exists(textBox1.Text.Trim()) == false) { MessageBox.Show("Invalid Directory Name or Path. Please Select a Valid Directory."); return; } if (textBox1.Text == "C:\\") { MessageBox.Show("Invalid Directory Name or Path. Please Select a Valid Directory."); return; } richTextBox1.Clear(); circularProgressBar1.Value = 0; circularProgressBar1.Text = "0%"; circularProgressBar1.Refresh(); richTextBox1.AppendText("Process Started At : " + System.DateTime.Now.ToLocalTime().ToString() + '\n'); stp.Start(); BGWorker.RunWorkerAsync(); }
private void SearchButton_Click(object sender, EventArgs e) { string[] Elements = "h,he,li,be,b,c,n,o,f,ne,na,mg,al,si,p,s,cl,ar,k,ca,sc,ti,v,cr,mn,fe,co,ni,cu,zn,ga,ge,as,se,br,kr,rb,sr,y,zr,nb,mo,tc,ru,rh,pd,ag,cd,in,sn,sb,te,i,xe,cs,ba,la,ce,pr,nd,pm,sm,eu,gd,tb,dy,ho,er,tm,yb,lu,hf,ta,w,re,os,ir,pt,au,hg,ti,pb,bi,po,at,rn,fr,ra,ac,th,pa,u,np,pu,am,cm,bk,cf,es,fm,md,no,lr,rf,db,sg,bh,mt,ds,rg,uub,uut,uuq,uup,uuh,uus,uuo".Split(new char[] { ',' }); List <string> el = Elements.ToList <string>(); if (!SearchByName) { int n; if (Int32.TryParse(this.TBSearch.Text, out n)) { if (n <= 0 || n > 118) { MessageBox.Show("The element number must be a number between 1 and 118.", "Out of Range", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3); } else { this.elementString = AgilityParser.GetElement(n - 1); } } } else { if (elementString.Length > 3) { MessageBox.Show("The element symbol must be 3 digits long by maximum.", "Out of Range", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3); } else if (!el.Contains(this.TBSearch.Text.ToLower())) { MessageBox.Show("Unknown element.", "Unknown Element;", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3); } else { this.elementString = this.TBSearch.Text.ToLower(); } } if (!BGWorker.IsBusy) { BGWorker.RunWorkerAsync(); } }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { if (BGWorker.CancellationPending) { e.Cancel = true; } else { M3uData msg = e.Argument as M3uData; for (int i = 0; i < msg.listbox.CheckedItems.Count; i++) { if (!msg.mngr.Copy_File(msg.listbox.CheckedItems[i].ToString(), msg.folder)) { BGWorker.CancelAsync(); } int percentComplete = (int)((i + 1) * 100) / msg.listbox.CheckedItems.Count; BGWorker.ReportProgress(percentComplete); } } }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { if (string.IsNullOrWhiteSpace(WorkingDirectory)) { throw new ArgumentNullException(nameof(WorkingDirectory)); } if (string.IsNullOrWhiteSpace(Action)) { throw new ArgumentNullException(nameof(Action)); } pluginManager.LoadPlugins(); var detail = pluginManager.SelectPlugin(Action); BGWorker.ReportProgress(0, detail); pluginManager.InitializePlugin(); pluginManager.ExecutePlugin(WorkingDirectory); }
private void StartButton_Click(object sender, EventArgs e) { //BenderBox.Image = null; //FryBox.Image = null; saveFileDialog.FileName = System.DateTime.Now.ToString("yyyy-MM-dd") + " - PlugNChug.txt"; if (saveFileDialog.ShowDialog() != DialogResult.Cancel) { VarBox.Enabled = false; CodeBox.Enabled = false; StartButton.Enabled = false; BgWorkerInformation BgInfo = new BgWorkerInformation(); BgInfo.VarText = VarBox.Text; BgInfo.CodeText = CodeBox.Text; BgInfo.FileOutputLocation = saveFileDialog.FileName; BGWorker.RunWorkerAsync(BgInfo); } }
private void BGWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { DependencyManifest NewTargetManifest; if (!ReadXmlObject(GitDepsPath, out NewTargetManifest)) { return; } Dictionary <string, string> TargetPacks = new Dictionary <string, string>(); foreach (DependencyPack NewPack in NewTargetManifest.Packs) { TargetPacks.Add(NewPack.Hash, NewPack.RemotePath); } string[] Files = Directory.GetFiles(CachePath, @"*", SearchOption.AllDirectories); int Count = 0; foreach (string FileEntry in Files) { string Filename = Path.GetFileName(FileEntry); if (TargetPacks.ContainsKey(Filename)) { string TargetPackPath = Path.Combine(TargetPath, TargetPacks[Filename]); Directory.CreateDirectory(TargetPackPath); if (!Directory.Exists(TargetPackPath)) { Console.WriteLine("Failed to create path {0}", TargetPackPath); continue; } File.Copy(FileEntry, Path.Combine(TargetPackPath, Filename)); } BGWorker.ReportProgress(++Count * 100 / Files.Length); } }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { if (textBox1.Text.Trim() == "") { BGWorker.CancelAsync(); MessageBox.Show("Cannot work on an empty directory. Select a valid Directory first."); } int i = 0; int count = 0; string[] files = { }; // Obtain all the files from the selected directory if (slideButton3.IsOn) { files = System.IO.Directory.GetFiles(textBox1.Text.Trim(), "*.*", SearchOption.AllDirectories); } else { files = System.IO.Directory.GetFiles(textBox1.Text.Trim(), "*.*", SearchOption.TopDirectoryOnly); } // Get File Size long totalsize = GetSizeOfAllFiles(files.ToList <string>()); long processedSize = 0; // UI Update int len = files.Length; richTextBox1.AppendText("Total Files Scanned : " + len + '\n'); // Cycle through each filter to obtain Group specific files from the directory. for (i = 0; i < listView1.Items.Count - 1; i++) { // Split the filters into individual filter string[] filters = listView1.Items[i].SubItems[1].Text.Split(','); // Obtain the folder name from the filter group string folder = listView1.Items[i].Text.Trim(); // Generate the complete folder path Dynamically string split_path = textBox1.Text.Trim() + "\\Arranged\\" + folder; // loop through each file to find the files that need to be split foreach (string fs in files) { // Get extension of file without the DOT(.) string ext = Path.GetExtension(fs).TrimStart('.').ToLower(); // If the file is suitable for processing then proceed for the process. if (IsPresent(filters, ext)) { // Validate the directory before starting file operation // This is done here, so that no useless/empty folders are created. if (Directory.Exists(split_path) == false) { Directory.CreateDirectory(split_path); richTextBox1.AppendText("Created Folder : " + folder + '\n'); } processedSize += GetSizeOfFile(fs); if (slideButton1.IsOn) { File.Move(fs, split_path + "\\" + Path.GetFileName(fs)); } else { File.Copy(fs, split_path + "\\" + Path.GetFileName(fs)); } count++; // Progress Update float prg = ((processedSize / totalsize) * 100); BGWorker.ReportProgress((int)prg); } } // UI Update richTextBox1.AppendText(folder + " : " + count + '\n'); count = 0; } }
private void ElementShowForm_Load(object sender, EventArgs e) { BGWorker.RunWorkerAsync(); }
private void BGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { BGWorker.RunWorkerAsync(); }
private void BGWorker_DoWork(object sender, DoWorkEventArgs e) { IsProcessOpen = Editor.M.OpenProcess("NOCD"); Thread.Sleep(100); BGWorker.ReportProgress(0); }
private void MainForm_Shown(object sender, EventArgs e) { BGWorker.RunWorkerAsync(); GamePanel.Size = new Size(1024, 768); }
private void Cock_Client_Shown(object sender, EventArgs e) { BGWorker.RunWorkerAsync(); }
private void Progress_Load(object sender, EventArgs e) { BGWorker.RunWorkerAsync(msg); }