backgroundworker

How Do I Create a Pool of Background Workers?

被刻印的时光 ゝ 提交于 2020-01-23 04:13:10
问题 I find that I am enjoying the simplicity of running code asynchronously through BackgroundWorkers. I have taught myself through example or trial and error on its uses, pitfalls, safe-threading etc., not so much the theory and perhaps my Achilles heel. I have done my reserach but one thing I don't find very much talk of, how can I effectively create and use a pool of BackgroundWorkers? Or what is a better alternative that is just as simple as using BWs? I will illustrate the problem I am

Calling BackgroundWorker synchronously

孤街浪徒 提交于 2020-01-22 14:53:32
问题 I want to call the background worker synchronously. I want execution of the code to end when backgroundworker has completed its execution. My code for BackgroundWorker is here : { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += DoWork; worker.RunWorkerCompleted += RunWorkerCompleted; ... worker.RunWorkerAsync(); //wait for execution to end } One way of doing it will be to check the status again n again until its execution is completed but is there any other good way of

Message queue architecture (client to web server to worker and back)

陌路散爱 提交于 2020-01-22 05:50:12
问题 I have a web server written in Node JS running on Heroku. The server has a web server process and a worker process. The web server successfully sends messages to the worker via a RabbitMQ queue; the worker successfully returns the processed data to the web server. I use a randomly generated Uuid to track the messages and ensure the right message is paired up with the right original message. In a separate project, I have the client (website) successfully communicating with the web server. Now,

VB 2013 Application Out of Memory

梦想的初衷 提交于 2020-01-17 02:55:49
问题 I'm new to VB but recently created my first working app :) Anyway it just compresses files and little bit more. The latest thing that I added was a marquee style progress bar to animate while the operation was in progress and stop when it ends and the user can do the next zip operation. The progress bar wasn't updating, so I used a background worker to do the actual task while the button click just did the animation. Since then I've notcied serious degredation in the app. It struggles to load

BackgroundWorker dies unexpectedly

拥有回忆 提交于 2020-01-15 12:19:48
问题 I have the following code: public Mainform() { ... // scheduler scheduler.DoWork += new System.ComponentModel.DoWorkEventHandler(scheduler_DoWork); scheduler.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(scheduler_RunWorkerCompleted); scheduler.WorkerReportsProgress = false; scheduler.WorkerSupportsCancellation = true; ... ... scheduler_DoWork(this, null); scheduler.RunWorkerAsync(1000); ... } void scheduler_RunWorkerCompleted(object sender, System

Update UI from a different thread in a different class

偶尔善良 提交于 2020-01-15 05:51:04
问题 I have the main form class which contains a list box I want to change. The box is populated with items created in a time-consuming method. Right now it looks like this (inventing an example by hand, might not be valid C#): List<string> strings = StaticClassHelper.GetStrings(inputString); foreach(string s in strings) { listBox1.Add(s); } //meanwhile, in a different class, in a different file... public static List<string> GetStrings(inputString) { List<string> result = new List<string>();

How to implement a progress bar in windows forms C#?

雨燕双飞 提交于 2020-01-15 04:38:48
问题 I have my own solution to import monthly sales data in my windows form application. When a user click on import button, the program is actually running but it looks like it's not responding. The process takes a long time about 5 minutes. So, I'd like to implement a progress bar with status strip label to display as an user interface and let the users know how much the task is done. This is also my first time using a progress bar in my program. So, I read through some tutorials which show how

BackgroundWorker.RunWorkerCompleted and threading

我怕爱的太早我们不能终老 提交于 2020-01-14 04:27:11
问题 AFAIK, this event is promised to be called in the creator thread (BackgroundWorker RunWorkerCompleted Event); and in the most cases, it does as promised. However, sometimes RunWorkerCompleted is called not in the thread that created BackgroundWorker object. Update: Code is like this: Trace.WriteLine(Thread.CurrentThread.ManagedThreadId); var worker = new BackgroundWorker(); worker.DoWork += (s, args) => Trace.WriteLine(Thread.CurrentThread.ManagedThreadId); worker.RunWorkerCompleted += (s,

Calling SignalR service from a BackgroundWorker in ABP

≯℡__Kan透↙ 提交于 2020-01-14 03:21:10
问题 I have a BackgroundWorker which is supposed to broadcast something to all online clients in 5 seconds interval: DeactivationBackgroundWorker: public class DeactivationBackgroundWorker : PeriodicBackgroundWorkerBase, ISingletonDependency { private readonly IRepository<HitchRequest, long> _hitchRequestRepository; private readonly IHitchHub _hitchHub; public DeactivationBackgroundWorker(AbpTimer timer, IRepository<HitchRequest, long> hitchRequestRepository, IHitchHub hitchHub) : base(timer) {

Fill dataGridView thank's to backGroundWorker

独自空忆成欢 提交于 2020-01-13 10:05:31
问题 I have this code snippet: private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { remplirDataGrid(); } private void frmChercherActesLoad(object sender, EventArgs e) { backgroundWorker1.RunWorkerAsync(); } private void remplirDataGrid() { dataGridView1.DataSource = ActeServices.getAllActes(0, 40); dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].HeaderText = "Code acte"; dataGridView1.Columns[2].HeaderText = "Désignation"; dataGridView1