Currently, my team and I have 2 types of databases that are updated periodically, SQL Server and Access. Also, we run specialized reports based on those databases.
Basically, we have 4 tasks that need to be completed:
- Update SQL Server
- Publish SQL Server Reports
- Update Access Databases
- Publish Access Db reports
Access takes forever to run, so I am trying to make my code run the task of Updating Access and Publishing Access reports at the same time that I am updating SQL Server and publishing those reports.
Can someone verify if I am on the right path, or maybe share a link that better explains async?
static void Main(string[] args)
{
var cs1 = new _1_UpdateSQL();
var cs2 = new _2_PublishSQLRpts();
Task t = TriggerAccess();
cs1.UpdateSqlCodeOnly();
cs2.PublishSqlRptsCodeOnly();
t.Wait();
}
static async Task TriggerAccess()
{
var cs3 = new _3_UpdateAccessDb();
var cs4 = new _4_PublishAccessRpts();
await Task.Run(() => cs3.UpdateAccessDbCodeOnly());
await Task.Run(() => cs4.PublishAccessRptsCodeOnly());
}
Start()
andasync
Task
will throw an exception. \$\endgroup\$