异步方法不能具有引用或输出参数

时间:2017-12-08 04:58:19

标签: c# .net asp.net-mvc asp.net-web-api

我想使用异步

来拨打电子邮件通知
   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;
        }
    }

这是我尝试的但它给了我一个错误

  

"异步方法不能具有引用或输出参数"。

    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;
    }       
  

给出错误:

     

错误CS1988异步方法不能有ref或out参数

我该如何解决这个问题?

0 个答案:

没有答案