I have a c# rules based application which is running a transaction which runs an SQL statement oven a large file. I want to run the final parts of the transaction as a background job. So for example seq 1 – 8 below are gathering data selection details and seq 9 – 10 are running the SQL statement and emailing the results back. Step 9 & 10 are independent steps and therefore need to be run synchronously in a background job.
Seq operation comment
1 Get user email Interactive
2 Get list of items Interactive
3 Get date range Interactive
4 .. Interactive
5 .. Interactive
6 .. Interactive
7 .. Interactive
8 Configure SQL statement Interactive
9 Run SQL Statement Background job synchronously, (populate datatable with result of the SQL statement)
10 Email results to user Background job synchronously, (emails results of SQL statement)
This command will email the results to the user email address. It should only run once Seq 9 is complete
11 GOTO Seq 1 Interactive
I have tried looking at task.RunSynchronously but this seems to run 10 & 11 in UI rather than in a background task. I have also looked a Background worker but it doesn't seem to have the ability to run synchronously. Appreciate if someone can suggest the best way to achieve what I am trying to do. If you can give an example - that would be great.
regards
Pat