Last active
October 30, 2017 11:18
-
-
Save shmutalov/c5a36bb6844e3d6ea0e36a687ae20f88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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