PC Review


Reply
Thread Tools Rate Thread

BackgroundWorker.ReportProgress Returns Before Event

 
 
Jonathan Wood
Guest
Posts: n/a
 
      12th Apr 2009
I didn't realize this but it appears that calling the
BackgroundWorker.ReportProgress method from the DoWork event returns before
the ProgressChanged event is handled.

This means that if I pass a detailed status object to the event, it's
possible that the DoWork handler could make changes to this status object
before the ProgressChanged event has reported that status.

Can someone confirm my understanding is correct, and is there a
straight-forward way to block DoWork until the event has been handled?

Thanks.

Jonathan

 
Reply With Quote
 
 
 
 
Jonathan Wood
Guest
Posts: n/a
 
      12th Apr 2009
"Peter Duniho" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...

Thanks for the detailed reply. I didn't understand it all but you gave me
some things to look into.

> All that said, I would suggest that if you're passing a complex data
> structure back for the ProgressChanged event, you might want to rethink
> that. The point of BackgroundWorker is simply to address the cross-thread
> issues for Forms or WPF components.


It's just a class--it's not that complex. I have some code that runs for
days and I want the display to show me the details of what is going on so I
pass an object that contains the various bits of information.

Perhaps it would be worth making a copy of the class object and passing the
copy. Never done that in C# but could always to it member-by-member if
needed.

Let's see... Looks like I'd need to implement IClonable in my class.

Thanks!

Jonathan

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BackgroundWorker.ReportProgress() Output Issue ray.ackley@gmail.com Microsoft VB .NET 3 29th Jan 2007 06:00 PM
BackGroundWorker.ReportProgress method doesn't accept strings jimmy Microsoft C# .NET 2 11th Jan 2007 06:32 PM
BackgroundWorker and RunWorkerCompleted event =?Utf-8?B?S2V2aW4gQnVydG9u?= Microsoft Dot NET Framework Forms 2 6th Sep 2006 01:21 AM
BackgroundWorker.ReportProgress() =?Utf-8?B?V0I=?= Microsoft Dot NET 0 1st Aug 2006 07:31 PM
BackgroundWorker.ProgressChanged Event =?Utf-8?B?V0I=?= Microsoft Dot NET 2 28th Apr 2006 10:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:00 AM.