Passing IJobCancellationToken into an async task/query

In our application, we’re using Hangfire to queue up long running database queries. However, on deleting the job, it doesn’t cancel the query. Doing some research, I have found that we need to pass IJobCancellationToken into our long running job when we run BackgroundJob.Enqueue(), IE

BackgroundJob.Enqueue(() => LongRunningMethod(JobCancellationToken.Null));

and then we are supposed to run:

public void LongRunningMethod(IJobCancellationToken cancellationToken)
    //Code here

However, all that is occurring in the Code here comment is a _db.Execute(someCommand); There is an async version of method called _db.ExecuteAsync(someCommand, CancellationToken); but I am not sure how to hook up the IJobCancellationToken to cancel the async CancellationToken. Is something like this possible? What’s the approach here?

You cannot.

I’ve created a pull request some time ago, but it is not merged yet. You can build it from source though (or use the workaround method proposed in the discussion there).

Interesting, will use the work around. Thanks. Any way to expedite this to getting merged? Seems like an important feature for long running asynchronous jobs.