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:
- 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
I think my approach seems viable, although I wonder if I could be doing something in an easier/more efficient way?
Any suggestions are greatly appreciated
1 Reply
Anyone got any ideas? Perhaps its overkill to use SignalR and should just create a ASP.NET endpoint/controller and query it ever second