Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WilbertOnGithub/b746c7297ca8237e3b3f to your computer and use it in GitHub Desktop.
Save WilbertOnGithub/b746c7297ca8237e3b3f to your computer and use it in GitHub Desktop.
QueueBackgroundWorkItem example
public class ValuesController1 : ApiController
{
// POST api/<controller>
public void Post([FromBody]string value)
{
HostingEnvironment.QueueBackgroundWorkItem(ct => StartBackgroundTask());
}
private async Task StartBackgroundTask()
{
/// Do your background work here.
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("http://www.google.com");
}
}
@asharzaman
Copy link

thank you, for the code...very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment