V
vulpes
How do I implement the "incremental results" with a BackgroundWorker?
Many pages,
http://msdn2.microsoft.com/en-us/library/wewwczdw.aspx
for example, tell that I should subclass the ProgressChangedEventArgs
class, but what else? I haven't found any examples. (Why aren't there
any?) Right now I have derived my own version of
ProgressChangedEventArgs with some extra properties, declared
public delegate void FilterWorkerProgressChanged(Object sender,
FilterProgressChangedEventArgs e);
public event FilterWorkerProgressChanged FilterProgressChanged;
in the publisher class and added a handler for this event here:
filterWorker.FilterProgressChanged +=
progDialog.filterWorker_ProgressChanged;
Of course, right now calling ReportProgress doesn't do anything
because it will raise a ProgressChanged event, which is unhandled. How
do I raise that FilterProgressChanged event or do I even need to make
my own event for this? I guess one way would be to subclass
BackgroundWorker, but that CANNOT be the easiest way to do it. And
then I would have to guess what to write to those overridden
ReportProgress, OnProgressChanged, etc., not good.
A simple (but rigorous) example would be the best answer. I just
started learning C# like two days ago (I like it thus far), so its
event handling model (or paradigm.........) is still a bit mystery to
me.
Thanks!
Many pages,
http://msdn2.microsoft.com/en-us/library/wewwczdw.aspx
for example, tell that I should subclass the ProgressChangedEventArgs
class, but what else? I haven't found any examples. (Why aren't there
any?) Right now I have derived my own version of
ProgressChangedEventArgs with some extra properties, declared
public delegate void FilterWorkerProgressChanged(Object sender,
FilterProgressChangedEventArgs e);
public event FilterWorkerProgressChanged FilterProgressChanged;
in the publisher class and added a handler for this event here:
filterWorker.FilterProgressChanged +=
progDialog.filterWorker_ProgressChanged;
Of course, right now calling ReportProgress doesn't do anything
because it will raise a ProgressChanged event, which is unhandled. How
do I raise that FilterProgressChanged event or do I even need to make
my own event for this? I guess one way would be to subclass
BackgroundWorker, but that CANNOT be the easiest way to do it. And
then I would have to guess what to write to those overridden
ReportProgress, OnProgressChanged, etc., not good.
A simple (but rigorous) example would be the best answer. I just
started learning C# like two days ago (I like it thus far), so its
event handling model (or paradigm.........) is still a bit mystery to
me.
Thanks!