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

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -