c# - Are async methods Thread Safe? -
this question has answer here:
let have application uses database. , whenever application starts backups database location. , backup process takes time.
to make gui responsive use async await. this;
public async task backupdatabase(){ using(sqlcommand command = new sqlcommand(@"backup database [mydatabase] disk = 'c:\....\mydatabase.bak'"), connection) { await command.executenonqueryasync(); } } my question is; can application use same connection query other things without need lock? or should lock connection while asynchronous method working?
even though new sqlconnection requesting possibly existing instance connection pool maintained internally in sqlconnection class.
generally speaking not blocking. can limit maximum pool size one, cause of app become unresponsive , suicide in web app.
the sql server @ keeping appropriate locks given nature of sql statement , guess code work.
it perhaps little unconventional make backup within application though, , become mess if ever scaled app horizontally more 1 web server.
so how scheduled task on sql server?
Comments
Post a Comment