How can I convert this singleton method to its equivalent with async
? I am trying to write something like this: public static async Task<DbContext> DBContext
.
public class ModelDB
{
static DbContext _dbContext;
readonly static object obj = new object();
public static DbContext DBContext
{
get
{
lock (obj)
{
if (_dbContext == null)
{
_dbContext = new MoviesDBEntities();
}
return _dbContext;
}
}
}
}