Play, pause, resume and stop functionality


#1

I want to add Play, Pause, Resume and Cancel functionality using hangfire library.

I had maintained one static list which has following columns
parentJobID, ParentJobProgressStatus = false(default), childJobId, childJobProgressStatus = false (default)

For Play functionality:-

1). I will enqueue the job and will get primaryJobId
2). Then I will call BackgroundJob.ContinueWith(primaryJobId, ()=> RemovedSuccessJobs(primaryJobId));
so that whenever primaryJobId gets completed successfully, primaryJobId will be removed from the shared list.
3). Then i will create an item with primaryJobID, primaryJobStatus = false, childJobID, childJobStatus = false and add it into list.

4). Called Thread.Sleep(3000):- just increase the program processing time.

For Cancel & Pause:-

I am removing all the jobs by using static list’s primaryJobID’s and childJobID’s.

For Resume:-
i will again follow at the step which i did for enqueuing jobs.

Now, my questions are

1). I am not able to use, since it show HttpContext == null inside background process. Can anyone give me suggestions why this happens and what is the solution for it.?

Please see attached file for reference.


#2

Hey were you able to make it with the code you specified above?