@@ -24,11 +24,11 @@ public static Process Start(ProcessStartInfo startInfo)
24
24
try
25
25
{
26
26
process = Process . Start ( startInfo ) ;
27
- process . PriorityClass = ProcessPriorityClass . Idle ;
28
27
}
29
28
catch ( Win32Exception exception )
30
29
{
31
- // NOTE: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 @asbjornu
30
+ // NOTE: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382.aspx
31
+ // -- @asbjornu
32
32
if ( exception . NativeErrorCode == 2 )
33
33
{
34
34
throw new FileNotFoundException ( string . Format ( "The executable file '{0}' could not be found." ,
@@ -39,6 +39,28 @@ public static Process Start(ProcessStartInfo startInfo)
39
39
40
40
throw ;
41
41
}
42
+
43
+ try
44
+ {
45
+ if ( process != null )
46
+ {
47
+ process . PriorityClass = ProcessPriorityClass . Idle ;
48
+ }
49
+ }
50
+ catch ( Win32Exception exception )
51
+ {
52
+
53
+ // NOTE: It seems like in some situations, setting the priority class will throw an exception
54
+ // with the error code set to "Success", which I think we can safely interpret as a success and
55
+ // not an exception.
56
+ // See https://travis-ci.org/GitTools/GitVersion/jobs/171288284#L2026
57
+ // and https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382.aspx
58
+ // -- @asbjornu
59
+ if ( exception . NativeErrorCode == 0 )
60
+ {
61
+ throw ;
62
+ }
63
+ }
42
64
}
43
65
}
44
66
@@ -137,7 +159,7 @@ public struct ChangeErrorMode : IDisposable
137
159
public ChangeErrorMode ( ErrorModes mode )
138
160
{
139
161
try
140
- {
162
+ {
141
163
oldMode = SetErrorMode ( ( int ) mode ) ;
142
164
}
143
165
catch ( EntryPointNotFoundException )
@@ -150,7 +172,7 @@ public ChangeErrorMode(ErrorModes mode)
150
172
void IDisposable . Dispose ( )
151
173
{
152
174
try
153
- {
175
+ {
154
176
SetErrorMode ( oldMode ) ;
155
177
}
156
178
catch ( EntryPointNotFoundException )
0 commit comments