public async Task GrantAuthAsync(bool verified, string username) { if (verified) { string selectQueryID = "SELECT ID FROM UserAccounts WHERE username = @username;"; //ConnectionManager.OpenInstanceConnection(); DbCommand dbCommand = ConnectionManager.GetConnection().CreateCommand(); ConnectionManager.CreateNamedParamater("@username", username, dbCommand); dbCommand.CommandText = selectQueryID; Task <DbDataReader> readerTask = dbCommand.ExecuteReaderAsync(); DbDataReader reader = await readerTask; //Temp assigned -1 to prevent data collision int tempID = -1; while (reader.Read()) { tempID = reader.GetInt32(0); } reader.Close(); reader.Dispose(); dbCommand.Dispose(); //ConnectionManager.CloseInstanceConnection(); //Create "AuthToken" UserSessionManager.CreateUserSessionInstance(tempID, username); } }