C# 使用MaxRetry图形API Timespan和MaxRetry
根据下面的截图。Graph API SDK有2个WithMaxRetry,一个带有timespan,另一个带有整数计数。问题是我需要结合timespan和times设置max retry,即:我希望每1秒重试3次。你知道如何实现代码吗?下面的代码会相应地工作吗C# 使用MaxRetry图形API Timespan和MaxRetry,c#,.net-core,microsoft-graph-api,C#,.net Core,Microsoft Graph Api,根据下面的截图。Graph API SDK有2个WithMaxRetry,一个带有timespan,另一个带有整数计数。问题是我需要结合timespan和times设置max retry,即:我希望每1秒重试3次。你知道如何实现代码吗?下面的代码会相应地工作吗 graphClient .Users["myuser@mydomain.com"] .MailFolders["myemailFOlder"] .Messages .Request(
graphClient
.Users["myuser@mydomain.com"]
.MailFolders["myemailFOlder"]
.Messages
.Request()
.WithMaxRetry(3)
.WithMaxRetry(new TimeSpan(1))
.Filter("myEmailFilter")
.GetAsync()
WithMaxRetry(T,Int32)
将最大重试次数设置为默认重试中间件
此请求的处理程序。这仅适用于默认重试
中间件处理程序。如果使用自定义重试中间件处理程序,则
必须在实现中处理它的检索
WithMaxRetry(T,TimeSpan)
将请求重试的最长时间设置为默认重试时间
此请求的中间件处理程序。这仅适用于默认设置
重试中间件处理程序。如果使用自定义重试中间件
处理程序,您必须在实现中处理它的检索
您唯一的问题是
Timespan
1秒时间跨度示例
// ... Use days, hours, minutes, seconds, milliseconds.
TimeSpan span = new TimeSpan(0, 0, 0, 1, 0);
或
因此,您的代码变成:
graphClient
.Users["myuser@mydomain.com"]
.MailFolders["myemailFOlder"]
.Messages
.Request()
.WithMaxRetry(3)
.WithMaxRetry(new TimeSpan(0, 0, 0, 1, 0))
.Filter("myEmailFilter")
.GetAsync()
当有文档可用时,不要粘贴代码的图像,当然也不要粘贴库代码的图像
graphClient
.Users["myuser@mydomain.com"]
.MailFolders["myemailFOlder"]
.Messages
.Request()
.WithMaxRetry(3)
.WithMaxRetry(new TimeSpan(0, 0, 0, 1, 0))
.Filter("myEmailFilter")
.GetAsync()