title: How to control the CurrentCulture for recurring jobs in HangFire
body: <p>I'm using HangFire 1.6 in an asp.net WebApi2 solution with Owin.</p>
  
  <p>The server is setup for one culture (da-DK) - I cannot change this. My application must use another culture (en-US) to correctly parse text data it receives. Basically I just want everything in my solution to use this other culture and never use the culture on the server.</p>
  
  <p>In my web.config I have:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;httpRuntime targetFramework="4.6.1" /&gt;
      &lt;globalization enableClientBasedCulture="false" culture="en-US" uiCulture="en-US"/&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>and in my <code>Startup</code> <code>Configuration</code> method I have</p>
  
  <pre><code>        CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentCulture;
          CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.CurrentUICulture;
  </code></pre>
  
  <p>because there are async methods and I want all threads started to share the same culture as specified in web.config</p>
  
  <p>I also have some recurring jobs running in HangFire</p>
  
  <p>My problem is that whatever I do the recurring jobs just keep using the server culture (da-DK) as CurrentCulture (the CurrentUICulture seems to react to what I do:
  <a href="https://i.stack.imgur.com/5i10Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5i10Y.png" alt="HangFireDashboard"></a></p>
  
  <p>I've searched the Hangfire docs and SO, but I have found nothing that could solve this for me. I would rather avoid having to hardcode a culture in the top of every method used in a recurring job</p>
  
  <p>Hope someone can help me...</p>
  
  <p><strong>Follow-up (2017-11-21):</strong></p>
  
  <p>It turns out this has nothing to do with HangFire. Apparently <code>CultureInfo.CurrentCulture</code> has not been set to the value provided in web.config when <code>Startup.Configuration</code> is run, hence <code>CultureInfo.DefaultThreadCurrentCulture</code> is set to a wrong value here. Once a controller executes the values are set to whatever is in the web.config.</p>
  
  <p>For now I've decided to hard-code the culture in the Startup class to make sure it has been set on DefaultThreadCurrentCulture before any of the Hangfire recurring jobs execute</p>