0

在下面代码的 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); 
    }
}
4

0 回答 0