Last active
July 21, 2020 11:38
-
-
Save burakcanekici/f92c6d4181750e82473e4b8c8df13ae7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[ApiController] | |
[Produces("application/json")] | |
[Route("api/[controller]/[action]")] | |
public class MyController : Controller { | |
... | |
private readonly MyBackgroundService _myBackgroundService; | |
public MyController(HostedService hostedService) | |
{ | |
... | |
_myBackgroundService = hostedService as MyBackgroundService; | |
... | |
} | |
[HttpPost] | |
public async Task<IActionResult> StartTask() | |
{ | |
... | |
await _myBackgroundService.StartAsync(new System.Threading.CancellationToken()); | |
... | |
} | |
[HttpPost] | |
public async Task<IActionResult> StopTask() | |
{ | |
... | |
await _myBackgroundService.StopAsync(new System.Threading.CancellationToken()); | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~be