Skip to content

Instantly share code, notes, and snippets.

@shmutalov
Last active October 30, 2017 11:18
Show Gist options
  • Save shmutalov/c5a36bb6844e3d6ea0e36a687ae20f88 to your computer and use it in GitHub Desktop.
Save shmutalov/c5a36bb6844e3d6ea0e36a687ae20f88 to your computer and use it in GitHub Desktop.
private void action()
{
...
// some very long process here which blocks the code execution
...
var context = GlobalHost.ConnectionManager.GetHubContext<SomeHub>();
context.Clients.All.FileReady("sample.txt");
}
...
// web-api controller
public class SomeController : ApiController
{
[Route("sample")]
[HttpPost]
public string Sample([FromBody] dynamic data)
{
...
new Task(action).Start(); // works fine
// doesn't work
//Task.Run(() => action());
//Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Current);
//Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
return "ok";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment