# IDurableJobHandler

Package: [Microsoft.Orleans.Durable](/orleans/docs/api/csharp/microsoft.orleans.durable/) 10.0.0-alpha.1

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/DurableJobs/IDurableJobHandler.cs#L100)

```csharp
public interface IDurableJobHandler
```

Defines the interface for handling durable job execution. Grains implement this interface to receive and process durable jobs.

## Remarks

Grains that implement this interface can be targeted by durable jobs. The [IDurableJobHandler](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.jobs.idurablejobhandler/) method is invoked when the job's due time is reached.

 The following example demonstrates a grain that implements [IDurableJobHandler](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.jobs.idurablejobhandler/): 

```csharp
public class MyGrain : Grain, IDurableJobHandler
             {
                 public Task ExecuteJobAsync(IJobRunContext context, CancellationToken attemptCancellationToken)
                 {
                     // Process the durable job
                     var jobName = context.Job.Name;
                     var dueTime = context.Job.DueTime;
            
                     // This token requests cancellation of this execution attempt, for example during silo shutdown.
                     // The durable job remains eligible for another attempt on another host.
                     attemptCancellationToken.ThrowIfCancellationRequested();
            
                     // Perform job logic here
            
                     return Task.CompletedTask;
                 }
             }
```

## Methods

- [ExecuteJobAsync(IJobRunContext, CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.jobs.idurablejobhandler/methods/executejobasync-orleans-durable-jobs-ijobruncontext-system-threading-cancellatio-aeb446df/)
