public GrabbedJob(GrabJob baseJob, GrabResponse response) : this() { this.ScheduledGrab = baseJob.ScheduledGrab; this.Response = response; this.WaitIndex = baseJob.WaitIndex; }
/// <summary> /// Grabs a batch of urls. /// </summary> /// <param name="scheduledGrabs">The scheduled grabs.</param> public void GrabUrls(IEnumerable<ScheduledGrab> grabs) { int jobCount = grabs.Count(); _handles = new ManualResetEvent[jobCount]; for (int i = 0; i < jobCount; i++) { var job = grabs.ElementAt(i); _handles[i] = new ManualResetEvent(false); if (_cancellationPending) return; GrabJob jobToRun = new GrabJob(job); jobToRun.Logger = this.Logger; jobToRun.WaitIndex = i; jobToRun.GrabComplete += new EventHandler<GrabCompleteEventArgs>(jobToRun_GrabComplete); jobToRun.GrabFailed += GrabFailed; jobToRun.GrabStarted += GrabStarted; Jobs.Add(jobToRun); jobToRun.Start(); //GrabCompleteEventArgs args = rwe.Result as GrabCompleteEventArgs; //if (args != null) { // if(GrabComplete != null) // GrabComplete(this, args); // _logger.Log("Grabbing complete"); //} //WaitHandle.WaitAll(_handles); // } }