This project is read-only.

Is this code still being actively updated

May 7, 2010 at 4:29 PM

I am having difficulties with the eventing model.  for the OnJobTransferred and the OnJobModified, I am receiving the arguments as JobNotificationEventArgs.  This class directly inherits from System.EventArgs.  By doing it this way, I am not getting the Job object so I can tell what job this is about.  I have followed the sample code that was provided.  It doesn't work either.  I noticed the last update was over a year ago.  Is the author still making updates?  Thanks.;

Scott.

Aug 22, 2012 at 7:38 PM

In case of someone came here with the same question here's what I did to the OnJobTransferred method. It's not beautiful, but it's a solution.

        void job_OnJobTransferred(object sender, JobNotificationEventArgs e)
        {
            foreach (var item in bitsManager.Jobs)
            {
                if (item.Value.State == JobState.Transferred)
                {
                    Log.Instance.Write("Job complete: " + item.Value.DisplayName);
                    bitsManager.Jobs[item.Key].Complete();
                }
            }
        }

Aug 23, 2012 at 4:19 PM

typically you can subscribe to the events for each particular Job (OnJobTransferred in BitsJob) to receive events for each single job. Otherwise if you subscribe to the generic event on BitsManager, JobErrorNotificationEventArgs has a public property BitsJob which refers to the job the current event is raised for.

I can't see any issues with the code provided, else please post some code or error message to provide further input.

Mar 3, 2015 at 6:57 PM
Hi,

This tripped me up too, since in the C++ API, I would typically use the same callback interface when adding a notification callback to a job. I expected the C# event to provide the job ID (since the same class is spawning many jobs). I didn't expect to need a separate handler for each job, but it turns out that's exactly what I was doing. I just wasn't storing the job Id.

I basically expected JobNotificationEventArgs to provide the same stuff that I'd get in a similar c++ interface (e.g. IBackgroundCopyError) and was confused when I didn't know what to cast it too or how to get any properties off it.

So do I still need to set the notification flags on each job if I install the corresponding event handler on the BitsManager?

-Jay
Mar 12, 2015 at 12:24 PM
ojcitt wrote:
So do I still need to set the notification flags on each job if I install the corresponding event handler on the BitsManager?

-Jay
if you handle events at the BitsManager Level, you'll not need separate eventhandlers for each particular job itself. It's just an option to chose the one or other model (or both) whatever suits your application best.