title: Hangfire Custom State Expiration
body: <p>I have implemented a custom state "blocked" that moves into the enqueued state after certain external requirements have been fulfilled. </p>
  
  <p>Sometimes these external requirements are never fulfilled which causes the job to be stuck in the blocked state. What I'd like to have is for jobs in this state to automatically expire after some configurable time.</p>
  
  <p>Is there any support for such a requirement? There is the <code>ExpirationDate</code> field, but from looking at the code it seems to be only used for <code>final</code> states. </p>
  
  <p>The state is as simple as can be:</p>
  
  <pre><code>    internal sealed class BlockedState : IState
      {
          internal const string STATE_NAME = "Blocked";
  
          public Dictionary&lt;string, string&gt; SerializeData()
          {
              return new Dictionary&lt;string, string&gt;();
          }
  
          public string Name =&gt; STATE_NAME;
  
          public string Reason =&gt; "Waiting for external resource";
  
          public bool IsFinal =&gt; false;
  
          public bool IgnoreJobLoadException =&gt; false;
      }
  </code></pre>
  
  <p>and is used simply as <code>_hangfireBackgroundJobClient.Create(() =&gt; Console.WriteLine("hello world"), new BlockedState());</code></p>
  
  <p>At a later stage it is then moved forward via <code>_hangfireBackgroundJobClient.ChangeState(jobId, new EnqueuedState(), BlockedState.STATE_NAME)</code></p>