backgroundworker

Long-running computations in node.js

大憨熊 提交于 2019-11-28 05:31:23
I'm writing a game server in node.js, and some operations involve heavy computation on part of the server. I don't want to stop accepting connections while I run those computations -- how can I run them in the background when node.js doesn't support threads? I can't vouch for either of these, personally, but if you're hell-bent on doing the work in-process, there have been a couple of independent implementations of the WebWorkers API for node, as listed on the node modules page: http://github.com/cramforce/node-worker http://github.com/pgriess/node-webworker At first glance, the second looks

This BackgroundWorker is currently busy and cannot run multiple tasks concurrently

时间秒杀一切 提交于 2019-11-28 05:13:18
I get this error if I click a button that starts the backgroundworker twice. This BackgroundWorker is currently busy and cannot run multiple tasks concurrently How can I avoid this? Simple: Don't start the BackgroundWorker twice. You can check if it is already running by using the IsBusy property, so just change this code: worker.RunWorkerAsync(); to this: if( !worker.IsBusy ) worker.RunWorkerAsync(); else MessageBox.Show("Can't run the worker twice!"); Update: If you do actually need to launch multiple background tasks at the same time, you can simply create multiple BackgroundWorker objects

How to update ObservableCollection from inside a BackgroundWorker using MVVM?

自古美人都是妖i 提交于 2019-11-28 04:11:26
问题 since two days I am trying to solve the following problem: I have a WPF control where a WrapPanel is bound to an ObservableCollection. An action changes the content of the ObservableCollection. The content is loaded in a BackgroundWorker. Immediately after the action that caused the content change, the new content is needed in a foreach-loop. The problem is that the loading of the content is slow, so it needs a bit to get ready. My first attempt was to wait for the backgroundworker until the

Updating UI with BackgroundWorker in WPF

夙愿已清 提交于 2019-11-28 03:32:10
问题 I am currently writing a simple WPF 3.5 application that utilizes the SharePoint COM to make calls to SharePoint sites and generate Group and User information. Since this process takes awhile I want to show a ProgressBar while the groups are being generated. The desired process is as follows: User enters url and clicks button to fetch site data. ProgressBar begins animation Groups are generated and names are added to a ListView Upon completion ProgressBar animation ends The problem I am

C# Background worker setting e.Result in DoWork and getting value back in WorkCompleted

心不动则不痛 提交于 2019-11-28 02:36:12
问题 C# 2008 SP1 I am using the background worker If one of the conditions fails I will set e.cancel to true, and assign the string to the e.result. Everything works there. However, when the workCompleted fires, I test for the e.Result and I get an exception "e.result throw an exception of type systeminvalidoperation". I guess I could use a global variable to set in the DoWork and compare in the work completed. But this might not be threadsafe. Can anyone tell me why I am getting this with the e

Node JS message queue on Heroku

时光毁灭记忆、已成空白 提交于 2019-11-28 00:50:12
问题 I need to move my Node JS server running on Heroku to a message queue architecture. Currently, the server receives a HTTP request, does some processing, and responds. The problem is that the processing takes some time, especially when there are lots of requests. This lengthy processing time causes the server to timeout, overload, and crash! My reading tells me a need a background worker to do the processing. I have zero experience with message queues and background workers and I'm looking for

Background Worker Check For When It's Midnight?

三世轮回 提交于 2019-11-28 00:04:44
I want to create a background worker for a WinForm that triggers code whenever midnight rolls by. I have an idea of how to do it, but I'm pretty sure it's not the best way to do it. while(1==1) { //if Datetime.Now == midnight, execute code //sleep(1second) } Use a System.Timers.Timer and at application start up just calculate the difference between DateTime.Now and DateTime.Today.AddDays(0) . Then set the interval for that amount. I actually did something just like this recently: public static class DayChangedNotifier { private static Timer timer; static DayChangedNotifier() { timer = new

Creating BackgroundWorker with Queue

≡放荡痞女 提交于 2019-11-27 22:27:34
I need to create queue and use it with BackgroundWorker. So I can add operations and when one is done next is starting in background. I found this code by google: public class QueuedBackgroundWorker<T> { public void QueueWorkItem( Queue queue, T inputArgument, Func<T> doWork, Action workerCompleted) { if (queue == null) throw new ArgumentNullException("queue"); BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = false; bw.WorkerSupportsCancellation = false; bw.DoWork += (sender, args) => { if (doWork != null) { args.Result = doWork(new DoWorkArgument<T>((T)args.Argument));

Throwing exceptions in callback method for Timers

时光怂恿深爱的人放手 提交于 2019-11-27 21:51:16
I was unable to find an answer to this question anywhere... What happens with the exceptions thrown in the callback method for System.Threading.Timer, (or in the event handler for System.Timers.Timer). Is the exception propagated to the thread on which the timer was created or is the exception lost? What are the side-effects of throwing an exception within the timer's callback functions? What would be the right way to signalize to the timer's creation thread that the exception in the worker thread (callback method) has been thrown? Thanks for your time. The exception is not passed back to the

How is BackgroundWorker.CancellationPending thread-safe?

柔情痞子 提交于 2019-11-27 20:32:59
问题 The way to cancel a BackgroundWorker's operation is to call BackgroundWorker.CancelAsync() : // RUNNING IN UI THREAD private void cancelButton_Click(object sender, EventArgs e) { backgroundWorker.CancelAsync(); } In a BackgroundWorker.DoWork event handler, we check BackgroundWorker.CancellationPending : // RUNNING IN WORKER THREAD void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { while (!backgroundWorker.CancellationPending) { DoSomething(); } } The above idea is all over the