我创建了一个简单的场景来测试 Polly 我可能完全错了。如果它重试,重试变量应该是 3。
请看看我做了什么。谢谢。
void Something(int Try)
{
try
{
if (Try <= 3)
throw new InvalidStudentNameException();
}
catch
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int retries = 0;
try
{
Something(retries);
var Result = retries;
var response = Policy
.Handle<InvalidStudentNameException>()
.Retry(3, (exception, attempt) =>
{
retries++;
})
.Execute
(() => Result);
int reachable = response;
}
//catch (InvalidStudentNameException SSSS)
//{
//}
finally
{
Response.Write(retries);
}
}
重试变量始终为零。又怎样 ?。