/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <param name="dependencyKey">The dependency key, if this is set to null the key is ignored.</param> /// <param name="ValidateRSCallBack">The delegate should contain the code to validate the callback.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsyncWithDependency(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyKey, DependencyValidateRSCallback ValidateRSCallBack) { if (mStatus != CompletionJobStatus.Unset && mStatus != CompletionJobStatus.Submitting) throw new JobException("The CompletionJob has already started executing. Call Reset()."); return AddJob(jobID, data, RSCallback, ProgressCallback, priority, dependencyKey, ValidateRSCallBack); }
/// <summary> /// This overriden method adds a job to the collection. Jobs with a dependency ID will be /// queued behind earlier jobs with the same ID. /// </summary> /// <param name="newJobID">The job identifier.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The callback.</param> /// <param name="ProgressCallback">The progress callback.</param> /// <param name="priority">The job priority.</param> /// <param name="dependencyID">The dependency identifier.</param> /// <param name="ValidateRSCallBack"></param> /// <returns>The job ID.</returns> protected virtual Guid AddJob(Guid newJobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyID, DependencyValidateRSCallback ValidateRSCallBack) { bool jobNotLinked = true; lock (this) { //Create the job holder object. JobHolder newJob = new JobHolder(newJobID, data, RSCallback, ProgressCallback, priority, null, null, ValidateRSCallBack); //OK, let's continue as normal. //Add the job. WorkTable.Add(newJob); if (dependencyID != null) { //Register the dependency job in the dependency tree. jobNotLinked = RegisterLinkedJob(dependencyID, newJobID); newJob.DependencyID = dependencyID; } Interlocked.Increment(ref jobRequests); if (JobShouldTrace) { string dependencyInfo = ""; if (dependencyID != null) { dependencyInfo = " Dependency: " + dependencyID + " " + (string)(jobNotLinked ? "Not Linked" : "Linked"); } JobTrace("-->" + jobRequests.ToString() + " CJ=" + CompletionJobID.ToString() + " Job=" + newJobID.ToString() + dependencyInfo); } } if (autoExecute && jobNotLinked) SubmitJob(newJobID); return newJobID; }
/// <summary> /// This is the internal constructor for the job. /// </summary> /// <param name="jobID">The job ID.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The request progress callback.</param> /// <param name="ProgressCallback">The request progress callback.</param> /// <param name="priority">The job priority.</param> /// <param name="NextJob">The next job for linked jobs.</param> /// <param name="LastJob">The last job for linked jobs.</param> public JobHolder(Guid? jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, Guid? NextJob, Guid? LastJob, DependencyValidateRSCallback ValidateRSCallBack) { mjobID = jobID; mPriority = priority; mData = data; mRSCallback = RSCallback; mProgressCallback = ProgressCallback; mNextJob = NextJob; mLastJob = LastJob; }