c#引用正确的参数类型

时间:2013-09-12 14:10:52

标签: c#

在下面的代码中的Worker.SendMail中,我需要将自己的引用传递给RetryEmailSend方法,但我不确定如何引用它。任何帮助,将不胜感激。

public class Worker
 {
    public bool SendMail()
    {
        try
        {
            //implementation
        }
        catch (Exception ex)
        {
            RetryEmailSend(NEED REFERENCE TO THIS INSTANCE Worker.SendMail());
        }
        return true;
    }
 }

 public static class Util
 {
    public static bool RetryAction(Action action)
    {
        if (action == null)
            throw new ArgumentNullException("action"); 

            try { action(); return true; }
            catch
            {
                return false;
            }
    }

    public static bool RetryEmailSend(NEED INPUT TYPE HERE)
    {
        return Util.RetryAction(() => INPUT TYPE); 
    }
}

0 个答案:

没有答案