backgroundworker

Should I use BackgroundWorker or Threads when I need to scrape a website?

I'm going to screen-scrape a gaming website for some data. I'd like to be able to send multiple requests so I can screen-scrape several pages at once. I've emailed the site administrator and gotten permission to scrape at a moderate rate (a few requests per second). As far as I know BackgroundWorker uses the thread-pool which I think ...

BackgroundWorker limitation on Windows server 2003

I am currently having an issue with BackgroundWorker running on Windows Server 2003. I have a window application that need to run more than 50 threads. The code I wrote use BackgroundWorker(BW) as a Thread wrapper to update data onto a window form. The issue is that the code are able to run more than 50 BWs on my XP machine, but stop at...

How to Unit test BackgroundWorker C#

I'm trying to unit test, using VS unit testing facility following method. void Get(string name, Action<string> callBack); here is unit tester [TestMethod] public void Test() { Action<string> cb = name => { Assert.IsNotNull(name); }; var d = new MyClass(); d.Get("tes...

Using Backgroundworker in a class and generate events for client application

i have designed a class for posting data to server, which is a time consuming task so that i have used background worker in my application. instead of repeatedly using backgroundworker in my application, i decided to add it to my class and generate two events PostWorkerReportProgress, PostWorkerComplted for my application. how can i do t...

Best ASP.NET Background Service Implementation

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 work...

What if I need to use the UI thread of a WPF application to do a long processing task on a UI element, but also update a progress bar on the same window?

My program consists of a large graphing UI control that I need to spend about 15 seconds re-loading every once in a while. Because the updating code works primarily with the UI control (maybe 90% of it actually sets properties on the control), it would make sense to me to actually let the UI thread handle that. I really don't want the ...

Changing the value of a node in an asynchronous TreeView

I have a treeview using BackGround worker to add nodes when you expand any. I display a "Loading.." message after the expand and remove it after the nodes are loaded. It works fine and all. Now I want to change the loading message to "Loading...node n/n". I was able to do it but the problem is this message is not displayed(updated to) wh...

Disable form while BackgroundWorker is busy?

I don't want the user to interact with my application while a certain backgroundworker is busy (working). I created this bgw so that the application doesn't look frozen when it's working. But now users can move around in the app. How do I disable my form/application? Thanks! ...

C# Winform ProgressBar and BackgroundWorker

I have a problem like this : I have a Form named MainForm. I have a long operation to be taken place on this form. While this long operation is going on, I need to show another from named ProgressForm on top of the MainForm. ProgressForm contains a progress bar. Which needs to be updated while the long operation is taking place. Af...

C# BackgroundWorker Thread Problem

using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Threading; namespace ClassLibrary { public class MyClass { public static string LongOperation() { Thread.Sleep(new TimeSpan(0,0,30)); return "HelloWorld"; } } } using S...

Windows Service that runs Periodically

I'm writing a windows service that once started will run every X hours. The process it completes is fairly intensive, so I want to use a background worker. I'm using a Settings file to store both the hours between runs and the last time the service ran. I'm not exactly sure the best way to do this - that is, I want the service to idle...

Backgroundworker thread throws nullreferenceexception

Hi, I am loading the images using the BackgroundThread. I am receving "nullreferenceexception unhandled by user code" after loading all the images into the Listview. What could be the issue? Please let me know. private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { int progress...

BackgroundWorker vs background Thread

I have a stylistic question about the choice of background thread implementation I should use on a windows form app. Currently I have a BackgroundWorker on a form that has an infinite (while(true)) loop. In this loop I use WaitHandle.WaitAny to keep the thread snoozing until something of interest happens. One of the event handles I wait ...

C# - Populating Panel with controls from BackgroundWorker

So I am writing a small Twitter client for me to use. I am using a combination of one big panel, with smaller panels representing the individual tweets. In each smaller panel, I have a PictureBox and a RichTextBox. Now, my problem is that loading more than 10 tweets causes a slowdown because I am dynamically generating the panels. So I ...

How to forward asynchronous events to parent classes?

I'm unsure as to what is the best approach for passing events down the line to parent classes and in need of some feedback. The example code below tries to illustrate what I want to achieve. namespace test { public delegate void TestCompletedEventHandler(object sender, TestCompletedEventArgs e); public class Manager { ...

.net website BackgroundWorker. Is it a good idea?

I am planing to use BackgroundWorker on my .net site to perform some database maintenance every night at 12:00. Is it a good idea to have asynch proccess monitoring time and perform action? I am using sql server express edition so i can't use any scheduling on database side. I also don't want to use windows task scheduler ...

Set a background process and allow the user to continue without waiting

Hi, I have a newsletter tool that I am trying to setup to run as a background process to send out the emails. The code below works without any issues but the problem I have is that it is slow. If there are 50 emails to send it can be very slow for the end user as they have to stare at the screen for up to 1min 30secs. This becomes a bi...

background task with an asp.net web application

Is this the technique to run a background job every x minutes: http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem%28VS.71%29.aspx So would I load this in the global.asax? ...

Removing a Control from a Form

Hello, So I've got some serious problems with removing a Control from a Form of my application. It's kinda messed up but I can't change anything. I have a form and I have a separated user Control. The control opens an exe file and shows a progress bar while loading it's bytes. And here comes the problem. I do all of it with a BackgroundW...

Testing a background worker with rhino mocks

lets say i have a background worker in a class that perform db query in a background thread. i wanna test this class so i mock my db and return some collection so far so good, make sure my background worker called the do work and than i wanna make sure that the finish also happened. I've noticed that the test pass and fail randomly (...