backgroundworker

.NET Web Service & BackgroundWorker threads

Hi Folks, I'm trying to do some async stuff in a webservice method. Let say i have the following API call: http://www.mysite.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 a...

Confused about BackgroundWorker events not firing

This may seem like a somewhat contrived example, but I'm left scratching my head. Ok, I have a console app that instantiates a WindowsForm and calls a method called DoSomeWork() on the form. class Program { static void Main(string[] args) { Form1 form = new Form1(); form.DoSomeWork(); } } Form...

When will my BackgroundWorker instance be garbage collected

consider this code block public void ManageInstalledComponentsUpdate() { IUpdateView view = new UpdaterForm(); BackgroundWorker worker = new BackgroundWorker(); Update update = new Update(); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; ...

"Streaming" results to a DataGridView from a BackgroundWorker

Is there a way to "stream" a set of results (eg. a DataTable) from a BackgroundWorker to a DataGridView. What I want to do is to query data, and fill the results in a DataGridView as they come (like query grid results in SQL Server Management Studio). My first thought was to use a BackgroundWorker (to avoid the UI freeze effect), but the...

Unhandled exceptions in BackgroundWorker

My WinForms app uses a number of BackgroundWorker objects to retrieve information from a database. I'm using BackgroundWorker because it allows the UI to remain unblocked during long-running database queries and it simplifies the threading model for me. I'm getting occasional DatabaseExceptions in some of these background threads, and I...

Background filling a DataGridView from an SqlDataAdapter

I have a large dataset (over 100,000 records) that I wish to load into a DataGridView. The stored procedure that does this can take 10 seconds or more to complete. So far I have a BackgroundWorker preventing the UI from locking up, and have implemented a rudimentary 'Please Wait' dialog. What I'd like to do is somehow populate the Data...

BackgroundWorker thread : updating UI and aborting operation

I run a series of time consuming operations on a background worker thread. At various stages I update a (windows form) progress bar by invoking a delegate. However, one of the more time operations occurs on a single line of code. Is it possible to : a) Update the UI while that single line of code is being executed, or at least displa...

Why does a call to unmanaged code from a .NET BackgroundWorker thread affect the UI?

I have a long running series of operations in a .NET 2.0 BackgroundWorker thread. When I make a call to unmanaged code located in a referenced assembly the UI is frozen until the call completes. Why is this? Should I not be making these calls from the BackgroundWorker thread? ...

C#/Winform: Enter data into HTML page, submit form

I have a Winform with a BackgroundWorker. The BackgroundWorker, among other things, has to make an HTTP call to a page, fill out some data, submit the form, and retrieve the HTML that comes back after "clicking" the submit button. I've run into a number of roadblocks while doing this: Can't POST the data because the target webserver do...

C# Can I add values to a listbox with a backgroundwork thread?

Hi I want my backgroundworker to add items to a list box, it appears to do so when debugging but the listbox doesn't show the values. I suspect this is something to do with adding items whilst inside the backgroundworker thread, do I need to add these to an array and then populate the list box from the array during backgroundWorker1_Run...

Synchronous work in a BackgroundWorker

My application performs time consuming work independently on several files. I created a BackgroundWorker to pass the work off to on each file, but it appears the backgroundworker is only capable of performing asynchronous work. Is it possible to do several asynchronous tasks in unison with it, or is there a similar object for performin...

Marquee ProgressBar unresponsive with BackgroundWorker

In my code, when a button is clicked the progress bar is set to marquee and then my BackgroundWorker is called but when the BackgroundWorker is called the progress bar freezes or disappears. I use the BackgroundWorker to seperate the RefreshReport method of the ReportViewer from the UI thread. Any help is appreciated. Thanks! Privat...

Thread stops doing its job

We have a C# application that connects to a FTP server, downloads some files, disconnects, and after a certain amount of time (selected by the user through the UI) reconnects and repeats the process. We implemented this using BackgroundWorker, but we noticed that after running for a longer time, the program stopped logging its actions, b...

Main UI windows not updating control -Cross-thread operation not valid

Ok..here is the problem I have a main UI form that has a control container that i can add some buttons item to it,and also i have a backgroundworker object that starts up a listner. When the listner events fire, i would like to create a button in that control container on the main UI form. Everything seems to work fine until i try to ad...

Ftp connection problem

I have an application implemented with BackgroundWorker that periodically connects to ftp (for download and upload) using LumiSoft library. It works just fine but after a while (let's say 2 - 3 hours) the thread (backgroundworker) blocks under the Connect method (witch doesn't throw any exception). Here is the part of code that fails: ...

Letting something happen at a certain time with Rails

Like with browser games. User constructs building, and a timer is set for a specific date/time to finish the construction and spawn the building. I imagined having something like a deamon, but how would that work? To me it seems that spinning + polling is not the way to go. I looked at async_observer, but is that a good fit for somethin...

.NET Backgroundworker Object's Thread Priority

I am trying to use the .NET Backgroundworker Object in an application I am developing. All the material on the internet say that this object runs in the "background" but nowhere have I been able to confirm that this background thread indeed runs in a "low priority" mode. This question arises because in Windows (I assume) a background ta...

WPF: How to handle errors with a BackgroundWorker

I am a bit of a newbie when it comes to windows client programming. I have a background worker that has a DoWork event and a RunCompleted event wired up. If an exception gets thrown in DoWork, I want to make changes to my UI, however, I cant because it is in a different thread. I can communicate the error to RunCompleted, but that doesn'...

Is it possible to kill the BackgroundWorker's thread?

Hi misters, Is it possible "kill" the thread of a BackgroundWorker? In my DoWork event, I can't check the cancellation flag, because I have a blocking call to an external COM interface or a query to a database. CancelAsync doesn't cancel the call to COM. How can I do it, please ? Any suggestions will be very appreciated. Thanks in a...

What can I access from a BackgroundWorker without "Cross Threading"?

Hi, I realise that I can't access Form controls from the DoWork event handler of a BackgroundWorker. (And if I try to, I get an Exception, as expected). However, am I allowed to access other (custom) objects that exist on my Form? For instance, I've created a "Settings" class and instantiated it in my Form and I seem to be able to re...