Track Thread/Task Progress through SignalR/WebSockets
I have an ASP.NET Web Core API and an Angular project both connected.
In the dashboard of my Angular app, I want to have a section where I can see all the tasks that are running, and what exactly they are executing.
For example, if I call endpoint /CreateTask, it will fire off a webrequest every second for 60 seconds, and when the status property acquired from the http response is complete, it will save it in the database, then send an email etc (I just made this up).
I want to be able to see in my dashboard:
TaskName | CurrentAction
CreateTask-1512 | StartRequestLoop()
CreateTask-5191 | AddToDatabase()
I have thought of the following:
Any suggestions are greatly appreciated
In the dashboard of my Angular app, I want to have a section where I can see all the tasks that are running, and what exactly they are executing.
For example, if I call endpoint /CreateTask, it will fire off a webrequest every second for 60 seconds, and when the status property acquired from the http response is complete, it will save it in the database, then send an email etc (I just made this up).
I want to be able to see in my dashboard:
TaskName | CurrentAction
CreateTask-1512 | StartRequestLoop()
CreateTask-5191 | AddToDatabase()
I have thought of the following:
- Launch a thread at the very start of the WebAPI launch.
- Within this thread, start a WebSocket/SignalR
- Every X seconds, query all the open Threads (maybe there some library/.NET api for this?) and collect their ID & stacktrace, then format the stacktrace so it prints out JustMyCode (the first method call from my own code) and post it to SignalR
- Connect to SignalR/WebSocket in Angular and show table
Any suggestions are greatly appreciated