Reputation: 1175
As per the screenshot below. There are 2 WithMaxRetry for Graph API SDK, one with timespan and the other one is with integer count. The problem is I need to set max retry with a combination of timespan and times, ie: I would like to retry 3 times after every 1 second. Any Idea how to implement the code? Would this code below works accordingly?
graphClient
.Users["[email protected]"]
.MailFolders["myemailFOlder"]
.Messages
.Request()
.WithMaxRetry(3)
.WithMaxRetry(new TimeSpan(1))
.Filter("myEmailFilter")
.GetAsync()
BaseRequestExtensions.WithMaxRetry Method
WithMaxRetry<T>(T, Int32)
Sets the maximum number of retries to the default Retry Middleware Handler for this request. This only works with the default Retry Middleware Handler. If you use a custom Retry Middleware Handler, you have to handle it's retrieval in your implementation.
WithMaxRetry<T>(T, TimeSpan)
Sets the maximum time for request retries to the default Retry Middleware Handler for this request. This only works with the default Retry Middleware Handler. If you use a custom Retry Middleware Handler, you have to handle it's retrieval in your implementation.
Upvotes: 0
Views: 799
Reputation: 26440
Your only problem is the Timespan
1 Second Timespan example
// ... Use days, hours, minutes, seconds, milliseconds.
TimeSpan span = new TimeSpan(0, 0, 0, 1, 0);
Or TimeSpan.FromSeconds(int seconds)
TimeSpan.FromSeconds(1)
So your code becomes:
graphClient
.Users["[email protected]"]
.MailFolders["myemailFOlder"]
.Messages
.Request()
.WithMaxRetry(3)
.WithMaxRetry(new TimeSpan(0, 0, 0, 1, 0))
.Filter("myEmailFilter")
.GetAsync()
Upvotes: 2