backgroundworker

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

自作多情 提交于 2019-11-29 09:12:33
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.Result, and how can I solve this? Many thanks, private void bgwPrepareCall_DoWork(object sender,

Indeterminate Progress Bar

£可爱£侵袭症+ 提交于 2019-11-29 08:56:52
Currently, I have a button that when the user clicks on it, it looks for a specific CD-ROM drive that is ready and contains a file. Sometimes, when the user clicks on a button, the button click is mouse down and the program hangs for an indeterminate time until the computer reads the CD-ROM drive. I made my progress bar but I noticed a few things: 1) The program hangs/freezes before the method that checks the cd drives gets called. So I can't set the progress bar to display when the method is called. Seems like the program hangs when the button is clicked on and while the user puts in the CD

Using BackgroundWorker with ProgressBar in WPF

瘦欲@ 提交于 2019-11-29 08:11:00
Hi i have an App where one of the jobs will be convert an Excel and pass all the records to the DB. So this takes a little time because it's more than 7000 rows that i will get and insert into the DB. So because this job takes a little time, more than 3 minutes, I'd like to use a ProgressBar to report progress of this job. So if i am doing this Job in Class that i have created, how can i use the backgroundWorker to report the progress to the progessBar in my case? My objective is be accurate in the percentage of how the progress is going, and how i can use all this stuff to report the progress

Node JS message queue on Heroku

ε祈祈猫儿з 提交于 2019-11-29 07:17:32
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 a very simple example to get started. Can anyone suggest a simple, understandable module or example to

Displaying wait cursor in while backgroundworker is running

耗尽温柔 提交于 2019-11-29 06:19:14
问题 During the start of my windows application, I have to make a call to a web service to retrieve some default data to load onto my application. During the load of the form, I run a backgroundworker to retrieve this data. I want to display the wait cursor until this data is retrieved. How would I do this? I've tried setting the wait cursor before calling the backgroundworker to run. When I report a progress of 100 then I set it back to the default cursor. The wait cursor comes up but when I move

Best ASP.NET Background Service Implementation

强颜欢笑 提交于 2019-11-29 05:22:43
What's the best implementation for more than one background service in an ASP.NET application? Timer Callback Timer timer = new Timer(new TimerCallback(MyWorkCallback), HttpContext, 5000, 5000); Thread or ThreadPool Thread thread = new Thread(Work); thread.IsBackground = true; thread.Start(); BackgroundWorker BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(DoMyWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(DoMyWork_Completed); worker.RunWorkerAsync(); Caching like http://www.codeproject.com/KB/aspnet/ASPNETService.aspx (located

Using .NET BackgroundWorker class in console app

纵然是瞬间 提交于 2019-11-29 03:47:59
I am relatively new to .NET programming and multithreading in general, and was wondering if it is ok to use .NET provided BackgroundWorker to spawn off worker threads to do some work in a console application? From the various documentation online, I see that intent for this class is more for UI oriented applications, where you want to do some work in background, but keep the UI responsive, and report progress, cancelling processing if needed etc. In my case, basically I have a controller class where I want to spawn off multiple worker threads to do some processing (limiting the max number of

BackgroundWorker & Timer, reading only new lines of a log file?

老子叫甜甜 提交于 2019-11-29 02:55:53
问题 My application writes a log file (currently using log4net ). I'd like to setup a timer and a background worker to read the log file and print its content into some control in my form, while it's being written. I can't use the FileSystemWatcher class because seems broken: sometimes the event "changed" fires, sometimes do not. And it has an extremely low "pooling rate". So I created a Timer and a FileSystemWatcher. On the "tick" event of the timer, the background worker does its job. The

Display progress of execution through progress bar

一曲冷凌霜 提交于 2019-11-29 01:30:27
问题 I have a silly problem but i am stuck. I am executing a stored procedure form my code procedure takes time so for this I am displaying a progress bar, which shows the progress of execution, but stored procedure executes and there is nothing to which I increment the value of progress bar. This is my code void btnYes_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("Are you sure", "", MessageBoxButtons.YesNo)) { try { dbDataEntities db = new dbDataEntities(); string

.NET Web Service & BackgroundWorker threads

谁都会走 提交于 2019-11-28 21:26:57
问题 I'm trying to do some async stuff in a webservice method. Let say I have the following API call: http://www.example.com/api.asmx and the method is called GetProducts() . I this GetProducts methods, I do some stuff (eg. get data from database) then just before i return the result, I want to do some async stuff (eg. send me an email). So this is what I did. [WebMethod(Description = "Bal blah blah.")] public IList<Product> GetProducts() { // Blah blah blah .. // Get data from DB .. hi DB! // var