backgroundworker

C# How to report progress from within a class to a backgroundworker?

My winform calls a class which performs some copying actions. I'd like to show the progress of this on a form. I'd like to use the Backgroundworker, but I don't know how to report progress from the class to the form (/backgroundworker) ...

Get ip adresses on a lan with backgroundworker control

I want to get alive or dead ip addresses from a big lan. but it takes so many times. I decided to use backgroundworker here is my code: try { this.Status.Text = "Collecting Information..."; if(this.TxtWorkGroup.Text.Trim() == "") { MessageBox.Show("The Work Group name Should Not be Empty"); return; } ...

Is this thread/background worker design for a C# WPF application OK?

Being new to using threads etc in UI's, can I ask is the following simple design seem OK. Refer to diagram image at link here In particular: a) use of backgroundworker & backgroundworker ProgressChanged to have the aggregator work on a separate thread. So I would need a custom class/type that had all the data I'd need to pass back fro...

how to check for BackgroundWorker.CancellationPending when my thread has called another?

How should I check for a CancellationPending within a BackgroundWorker DoWork method, when within this method I call off to a Pcap.Net packet capture routine, which responses via a callback. The two options I can think of is: a) write a loop at the bottom of the DoWork method to continually check for CancellationPending b) put the che...

C# update and append textbox value using backgroundworker process

I've got a c# windows form app I threw together. It's fairly simple:\ inputs: text string source folder path destination folder path integer count The app searches through text files in the source folder for the entered text string; if it finds the string then it copies that file and an image file with the same name to the destin...

How do you call the GUI thread in Silverlight from the BackgroundWorker method ?

Hi, I am using a BackgroundWorker thread to do some work outside of the GUI thread in Silverlight 4. I would like to update widgets in the GUI context from the background thread, but have read warnings about doing so from Microsoft documentation. I understand that communicating from one thread to another throws an exception as only th...

C# WebRequest hanging with no timeout

I have built a WebRequest in a WPF application into a background worker, but it is hanging if the website does not return a 404 error. There is a timeout, and found that some people have also had the same problem with the timeout not working and making the WebRequest hang. I tried to implement the code recommended for fixing the hang whi...

C# BackgroundWorker DoWork event won't run

Hi, I created a WCF client service (a Windows service) in C# which starts a BackgroundWorker in the OnStart to do the core functionality in the background and leaving the main thread managing the service itself. Maybe this approach is overkill but it's working without problems on my dev machine. If I try to run it on the client machine...

BackgroundWorker questions.

I have UI WPF application. May by some one have any ideas why this code is not working? Case 1: BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += delegate { //some logic }; worker.RunWorkerAsync(); In that case i am getting exception The calling thread cannot access this object because a different thread owns i...

Rails backgroud job processing

I am using starling as a queue server in my rails application. so each time i want to call worker method, I have to start starling and workling client from console. Is there a way where as soon as the passenger is started my workling and starling both get auto started Or preciously when i will call the worker method then only my worlin...

Using BackgroundWorker in an object and updating UI

Edit: Got somewhere, I hope Here is what I've got, but I'm not so sure about how I delegate my bcLoad.ReportProgress(i) to the object created (ie how to make the delegate so it can be passed). I've created the object events which work sort of(I can call my object method and I can see a change triggered when reading in lines). I know w...

c# backgroundworker for socket application

Hi All, I am working on a C# windows application. This application is mainly related to sockets. I have a class called tcpsocket, which handles all socket level functionality of sending, receiving data, etc. A controller class calls this tcpsocket. In addition, it does all other work of logging data to a file and updating GUI. I though...

ASP.NET - Get website's URL without HttpContext.Current (running in background thread)

Bit of a long shot, but is there a way in ASP.NET to dynamically get the website's URL (http://www.example.com) when there is no HttpContext.Current available. There is no HttpContext because the code is running in a background thread* (but under the ASP.NET AppDomain). I have a background process that sends emails out every evening, an...

C# Background Worker UI Update

I am trying to use a background worker in order to retrieve a large amount of data from the database without stalling the main thread. This seems to work well, except that when it comes to update the UI, the update freezes the screen. Relevant code as follows: private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEve...

Perl: Waiting for background process to finish.

My problem is that when I run the following it will say that the bash script has finishes successfully. But it doesnt wait for the script to finish, if it quits to early it will move a file that it needs. So what am I doing wrong that it wont wait for the background process to finish to move the files? my $pid = fork(); if($pid == -...

Winform doesnot show up when i tried to open from a backgroundworker_RunWorkerCompleted event?

Hi the detail of my action is i have a winform which contains only progress bar which i made to do some calculations and stored the final value in db.for this i used progress bar and backgroundworker thread. i am doing all calculation in backgroundworker thread event doWork event. When backgroundworker is finish it calls RunWorkerComple...

A question about the ProcessStartInfo class and the Argument Property?

Some sample code: var psi = new ProcessStartInfo(); psi.FileName = "path to update.exe"; psi.Arguments = "arguments for update.exe"; psi.Verb = "runas"; var process = new Process(); process.StartInfo = psi; process.Start(); process.WaitForExit(); Ref: 0xA3. Programmatically in code what type of objects if possible could you pass ...

Background worker synchronization

Lets say I have a class that is supposed to generate some ID (for example GUID) for me. Now unfortunately the ID generation is a somewhat long process and if I need a hundred of those I run into a problem of significant slowdowns. In order to avoid those, I keep a queue of pre-generated ID, and when this queue starts to run down on them ...

Why would a threading-related exception only happening outside of the Visual Studio IDE/debugger?

I'm using a BackgroundWorker to do some work. Part of that work involves showing a form. That form has some controls that are set as drag & drop targets. I know that the BackgroundWorker uses the ThreadPool to run, and that threads from the thread pool use the MTA threading model. I also know (thanks to this question) that when you have...

Is it ok to use ReportProgress of a BackgroundWorker to do other stuff?

I'm writing a WPF app using an MVVM approach. In my ViewModel, I have an ObservableCollection. Periodically, my app needs to check for new messages, and, if there are any, it needs to add them to the ObservableCollection. If I try to add to the ObservableCollection in the DoWork, it doesn't work because of thread synchronization issue...