/// <summary> /// Marks a certain job as remotely failed. /// </summary> /// <param name="jobId">The job identifier.</param> public void FailJob(JobID jobId) { AsyncJob asyncJob = GetJob(jobId, andRemove: true); if (asyncJob == null) { // ignore remote failures for jobs we're not tracking return; } asyncJob.SetFailed(dueToRemoteFailure: true); }
/// <summary> /// Extends the lifetime of a job. /// </summary> /// <param name="jobId">The job identifier.</param> public void HeartbeatJob(JobID jobId) { AsyncJob asyncJob = GetJob(jobId); if (asyncJob == null) { // ignore heartbeats for jobs we're not tracking return; } asyncJob.Heartbeat(); }
AsyncJob <T> AttachIncompleteManipulationHandler <T>(AsyncJob <T> job) where T : CallbackMsg { // Manipulation requests typically complete (and are removed from lobbyManipulationRequests) when // a message is handled. However, jobs can also be faulted, or be cancelled (e.g. when SteamClient // disconnects.) Thus, when a job fails we remove the JobID/request from lobbyManipulationRequests. job.ToTask().ContinueWith(task => { lobbyManipulationRequests.TryRemove(job.JobID, out _); }, TaskContinuationOptions.NotOnRanToCompletion); return(job); }
/// <summary> /// Passes a callback to a pending async job. /// If the given callback completes the job, the job is removed from this manager. /// </summary> /// <param name="jobId">The JobID.</param> /// <param name="callback">The callback.</param> public void TryCompleteJob(JobID jobId, CallbackMsg callback) { AsyncJob asyncJob = GetJob(jobId); if (asyncJob == null) { // not a job we are tracking ourselves, can ignore it return; } // pass this callback into the job so it can determine if the job is finished (in the case of multiple responses to a job) bool jobFinished = asyncJob.AddResult(callback); if (jobFinished) { // if the job is finished, we can stop tracking it asyncJobs.TryRemove(jobId, out asyncJob); } }
/// <summary> /// Tracks a job with this manager. /// </summary> /// <param name="asyncJob">The asynchronous job to track.</param> public void StartJob(AsyncJob asyncJob) { asyncJobs.TryAdd(asyncJob, asyncJob); }
internal void StartJob(AsyncJob job) { jobManager.StartJob(job); }