Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Perform Control Transfer With Retry
public static Task<T> PerformControlTransferWithRetry<T>(
this IUsbDevice usbDevice,
Func<IUsbDevice, Task<T>> func,
int retryCount = 3,
int sleepDurationMilliseconds = 250)
var retryPolicy = Policy
i => TimeSpan.FromMilliseconds(sleepDurationMilliseconds),
onRetryAsync: (e, t) => usbDevice.ClearStatusAsync()
return retryPolicy.ExecuteAsync(() => func(usbDevice));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment