3
3
4
4
using System ;
5
5
using System . IO ;
6
- using System . IO . MemoryMappedFiles ;
7
- using System . Text ;
8
6
using System . Threading ;
9
7
10
8
namespace Microsoft . NET . HostModel
@@ -16,7 +14,6 @@ namespace Microsoft.NET.HostModel
16
14
/// causing the operations to fail with IO-Error.
17
15
/// So, the operations are retried a few times on failures such as
18
16
/// - IOException
19
- /// - Failure with Win32 errors indicating file-lock
20
17
/// </summary>
21
18
public static class RetryUtil
22
19
{
@@ -38,61 +35,5 @@ public static void RetryOnIOError(Action func)
38
35
}
39
36
}
40
37
}
41
-
42
- public static void RetryOnWin32Error ( Action func )
43
- {
44
- static bool IsKnownIrrecoverableError ( int hresult )
45
- {
46
- // Error codes are defined in winerror.h
47
- // The error code is stored in the lowest 16 bits of the HResult
48
-
49
- switch ( hresult & 0xffff )
50
- {
51
- case 0x00000001 : // ERROR_INVALID_FUNCTION
52
- case 0x00000002 : // ERROR_FILE_NOT_FOUND
53
- case 0x00000003 : // ERROR_PATH_NOT_FOUND
54
- case 0x00000006 : // ERROR_INVALID_HANDLE
55
- case 0x00000008 : // ERROR_NOT_ENOUGH_MEMORY
56
- case 0x0000000B : // ERROR_BAD_FORMAT
57
- case 0x0000000E : // ERROR_OUTOFMEMORY
58
- case 0x0000000F : // ERROR_INVALID_DRIVE
59
- case 0x00000012 : // ERROR_NO_MORE_FILES
60
- case 0x00000035 : // ERROR_BAD_NETPATH
61
- case 0x00000057 : // ERROR_INVALID_PARAMETER
62
- case 0x00000071 : // ERROR_NO_MORE_SEARCH_HANDLES
63
- case 0x00000072 : // ERROR_INVALID_TARGET_HANDLE
64
- case 0x00000078 : // ERROR_CALL_NOT_IMPLEMENTED
65
- case 0x0000007B : // ERROR_INVALID_NAME
66
- case 0x0000007C : // ERROR_INVALID_LEVEL
67
- case 0x0000007D : // ERROR_NO_VOLUME_LABEL
68
- case 0x0000009A : // ERROR_LABEL_TOO_LONG
69
- case 0x000000A0 : // ERROR_BAD_ARGUMENTS
70
- case 0x000000A1 : // ERROR_BAD_PATHNAME
71
- case 0x000000CE : // ERROR_FILENAME_EXCED_RANGE
72
- case 0x000000DF : // ERROR_FILE_TOO_LARGE
73
- case 0x000003ED : // ERROR_UNRECOGNIZED_VOLUME
74
- case 0x000003EE : // ERROR_FILE_INVALID
75
- case 0x00000651 : // ERROR_DEVICE_REMOVED
76
- return true ;
77
-
78
- default :
79
- return false ;
80
- }
81
- }
82
-
83
- for ( int i = 1 ; i <= NumberOfRetries ; i ++ )
84
- {
85
- try
86
- {
87
- func ( ) ;
88
- break ;
89
- }
90
- catch ( HResultException hrex )
91
- when ( i < NumberOfRetries && ! IsKnownIrrecoverableError ( hrex . Win32HResult ) )
92
- {
93
- Thread . Sleep ( NumMilliSecondsToWait ) ;
94
- }
95
- }
96
- }
97
38
}
98
39
}
0 commit comments