I want to call email notification using asynchronously
public void UpdatePassDetailsForLostCase(LostPassRequest objLostPassRequest, out TransactionalInformation transaction)
{
transaction = new TransactionalInformation();
try
{
_passDataService.UpdatePassDetailsForLostCase(objLostPassRequest);
transaction.ReturnStatus = true;
transaction.ReturnMessage.Add("Pass details updated successfully.");
}
catch (Exception ex)
{
transaction.ReturnMessage.Add(ex.Message);
transaction.ReturnStatus = false;
}
}
This is what I have tried but it is giving me an error
"Async methods cannot have ref or out parameters".
public async void UpdatePassDetailsForLostCase(LostPassRequest objLostPassRequest, out TransactionalInformation transaction)
{
transaction = new TransactionalInformation();
try
{
_passDataService.UpdatePassDetailsForLostCase(objLostPassRequest);
await EmailNotificationAsync(1, "LostPass", "LostPass");
transaction.ReturnStatus = true;
transaction.ReturnMessage.Add("Pass details updated successfully.");
}
catch (Exception ex)
{
transaction.ReturnMessage.Add(ex.Message);
transaction.ReturnStatus = false;
}
}
Task<int> EmailNotificationAsync(string passId, string actionName, string moduleName)
{
return Task.Run<int>(() =>
{
return EmailNotification(passId, actionName, moduleName);
});
}
private int EmailNotification(string passId, string actionName, string moduleName)
{
try
{
//Email Send Code
}
catch (Exception ex)
{
InsertErrorLog(moduleName, "EmailNotification", ex.Message); // Add error in database.
}
return 1;
}
Give the error:
Error CS1988 Async methods cannot have ref or out parameters
How can I workaround this?