Progress Without Refresh
This example is the Import Monitor panel of
TicketOps Live. An import of 200 simulated records runs on a task started from the click (Application.StartTask),
pushes progress to the browser every 10 records with Application.Update(this), supports cooperative cancellation
(CancellationTokenSource), can fail on purpose at record 87, and always restores the UI in finally. Every log
line carries a JobId (the extension challenge).
Run it
cd "LearnWisej-Samples/Real-Time Server Push Course/Module 3/TicketOpsLive"
dotnet run -f net10.0 --urls http://localhost:5303
Then open http://localhost:5303. (Visual Studio: open TicketOpsLive.slnx, press F5.)
What to try
| Button | What you should see |
|---|---|
| Start Import | the bar, recordsImportedLabel (n/200) and the elapsed time move without a refresh; the log gets "Import started", "Imported 50/100/150/200 records", "Import completed" and a summary line (Job J-xxxxxx: 200 records in 5.3 s — completed) |
| Cancel Import (while running) | the loop stops between two records: "Import cancelled by user.", "Cancelled at … after record n"; Start is enabled again |
| Fail at 87 | the import runs to record 86, then "Import failed. Review the server log." and "Failed at … on record 87"; the full exception is on the server console under the JobId; Start is enabled again |
Polling fallback. Add "enableWebSocket": false to Default.json and restart: progress still arrives on the
polls (about a second late); polling is requested when the import starts and ended when it finishes.