Esempio n. 1
0
        private static async ValueTask RetryOnSharingViolationAsync(Action action)
        {
            var attempt = 0;

            while (attempt < 10)
            {
                try
                {
                    action();
                    return;
                }
                catch (IOException ex) when(IOUtilities.IsSharingViolation(ex))
                {
                }

                attempt++;
                await Task.Delay(50).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        private static void RetryOnSharingViolation(Action action)
        {
            var attempt = 0;

            while (attempt < 10)
            {
                try
                {
                    action();
                    return;
                }
                catch (IOException ex) when(IOUtilities.IsSharingViolation(ex))
                {
                }

                attempt++;
                Thread.Sleep(50);
            }
        }