While studying asynchronous programming, I had the following question: Will the code be executed in parallel after the await keyword in an asynchronous function?
An example of such code:
FuncAsync("123", "123");
FuncAsync("123", "123");
public async Task FuncAsync(string login, string password)
{
try
{
var account = await DB.Accounts
.Find(a => a.Login == login)
.FirstOrDefaultAsync();
// Is GetHash() will be executed in parallel, when two methods FuncAsync called?
password = GetHash(password);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public static string GetHash(string password)
{
var hashed = BCrypt.Net.BCrypt.HashPassword(password, 12);
return hashed;
}
public static class DB
{
public static MongoClient Client = new MongoClient("url");
public static IMongoCollection<Account> Accounts = Client.GetDatabase("s").GetCollection<Account>("accounts");
}
Essentially, the first call to the database query function will be executed first, followed by the second call to the database query function. And then the code of each function will be executed sequentially or in parallel, each on its own thread?