# Using .Net Core CancellationToken instead of IJobCancellationToken

**URL:** <https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782>\
**Category:** question\
**Created:** [September 11, 2017, 1:25pm UTC](https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782 "2017-09-11T13:25:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexKovalskyi](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@AlexKovalskyi](https://discuss.hangfire.io/u/AlexKovalskyi)\
**Post date:** [September 11, 2017, 1:25pm UTC](https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782/1 "2017-09-11T13:25:00Z")

</div>

I would like to use `CancellationToken` from .net core.  
I passed it instead `IJobCancellationToken` like this:

```
public void LongRunningMethod(CancellationToken cancellationToken)
{
    for (var i = 0; i < Int32.MaxValue; i++)
    {
        cancellationToken.ThrowIfCancellationRequested();

        Thread.Sleep(TimeSpan.FromSeconds(1));
    }
}

```

start  
`BackgroundJob.Enqueue(() =>LongRunningMethod(CancellationToken.None));`

and it works fine, but i can’t stop this job using this:

`BackgroundJobClient.Delete("this_job_id")`

Is there any way to do this?

---

<div class="post-metadata">

**Author:** ![pieceofsummer](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/pieceofsummer/32/785_2.png) [@pieceofsummer](https://discuss.hangfire.io/u/pieceofsummer)\
**Post date:** [September 11, 2017, 3:39pm UTC](https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782/2 "2017-09-11T15:39:18Z")

</div>

There’s currently an open PR, but it is not merged yet. You can checkout and build it yourself though.

---

<div class="post-metadata">

**Author:** ![AlexKovalskyi](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@AlexKovalskyi](https://discuss.hangfire.io/u/AlexKovalskyi)\
**Post date:** [September 12, 2017, 8:29am UTC](https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782/3 "2017-09-12T08:29:19Z")

</div>

Can you give me a link? Thanks.

---

<div class="post-metadata">

**Author:** ![pieceofsummer](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/pieceofsummer/32/785_2.png) [@pieceofsummer](https://discuss.hangfire.io/u/pieceofsummer)\
**Post date:** [September 13, 2017, 7:14pm UTC](https://discuss.hangfire.io/t/using-net-core-cancellationtoken-instead-of-ijobcancellationtoken/3782/4 "2017-09-13T19:14:54Z")

</div>

> <https://github.com/HangfireIO/Hangfire/pull/976>
