public async Task Invoke(HttpContext httpContext, IHostingEnvironment env) { int delayInMs = _random.Value.Next(_minDelayInMs, _maxDelayInMs); FileProcessor fp = new FileProcessor(env); Havok myEnt = JsonConvert.DeserializeObject <Havok>(fp.LoadJsonFromAppFolder("\\", "havok.json")); if (myEnt.HavokEnabled == true && myEnt.isScaledOut == false) { await Task.Delay(delayInMs); } await _next(httpContext); }