Skip to main content

State, background work & errors

The background job runner from Module 6 · State, Sessions, Background Work & Errors, as the walkthrough video builds it: Start Import / Start Export, Cancel Job and Clear Log buttons, a progress bar, a status label and a timestamped job log. The job runs with async / await so the page stays responsive, the handler uses try / catch / finally, and the running job is kept in an instance field — per user — never in a static field.

Run it​

cd "LearnWisej-Samples/Foundations Course/Module 6/WisejTrainingApp"
dotnet run -f net10.0 --urls http://localhost:5086

Then open http://localhost:5086. (Visual Studio: open WisejTrainingApp.slnx, press F5.)

What to try​

ActionWhat you should see
Start ImportStart buttons disable, the bar and the log advance step by step, then Import completed successfully.
Cancel Job while it runsImport cancelled.; the buttons reset
Tick Simulate Error, Start Importthe log shows the technical error; the status shows only Import failed. Please try again or contact support.; the buttons reset

Where things live​

FileWhat it's for
JobsWindow.csThe handlers, RunJobAsync, SetJobRunning, LogError
JobsWindow.Designer.csThe layout — generated by the Designer