@@ -238,50 +238,48 @@ public void Start()
238238 /// <returns>A task that represents the asynchronous start operation.</returns>
239239 public async Task StartAsync ( )
240240 {
241- if ( this . driverServiceProcess ! = null )
241+ if ( this . driverServiceProcess = = null )
242242 {
243- return ;
244- }
245-
246- lock ( this . driverServiceProcessLock )
247- {
248-
249- if ( this . driverServiceProcess == null )
243+ lock ( this . driverServiceProcessLock )
250244 {
251- var driverServiceProcess = new Process ( ) ;
252245
253- try
246+ if ( this . driverServiceProcess == null )
254247 {
255- if ( this . DriverServicePath != null )
248+ var driverServiceProcess = new Process ( ) ;
249+
250+ try
256251 {
257- if ( this . DriverServiceExecutableName is null )
252+ if ( this . DriverServicePath != null )
253+ {
254+ if ( this . DriverServiceExecutableName is null )
255+ {
256+ throw new InvalidOperationException ( "If the driver service path is specified, the driver service executable name must be as well" ) ;
257+ }
258+
259+ driverServiceProcess . StartInfo . FileName = Path . Combine ( this . DriverServicePath , this . DriverServiceExecutableName ) ;
260+ }
261+ else
258262 {
259- throw new InvalidOperationException ( "If the driver service path is specified, the driver service executable name must be as well" ) ;
263+ driverServiceProcess . StartInfo . FileName = new DriverFinder ( this . GetDefaultDriverOptions ( ) ) . GetDriverPath ( ) ;
260264 }
261265
262- driverServiceProcess . StartInfo . FileName = Path . Combine ( this . DriverServicePath , this . DriverServiceExecutableName ) ;
266+ driverServiceProcess . StartInfo . Arguments = this . CommandLineArguments ;
267+ driverServiceProcess . StartInfo . UseShellExecute = false ;
268+ driverServiceProcess . StartInfo . CreateNoWindow = this . HideCommandPromptWindow ;
269+
270+ DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs ( driverServiceProcess . StartInfo ) ;
271+ this . OnDriverProcessStarting ( eventArgs ) ;
272+
273+ driverServiceProcess . Start ( ) ;
263274 }
264- else
275+ catch
265276 {
266- driverServiceProcess . StartInfo . FileName = new DriverFinder ( this . GetDefaultDriverOptions ( ) ) . GetDriverPath ( ) ;
277+ driverServiceProcess . Dispose ( ) ;
278+ throw ;
267279 }
268280
269- driverServiceProcess . StartInfo . Arguments = this . CommandLineArguments ;
270- driverServiceProcess . StartInfo . UseShellExecute = false ;
271- driverServiceProcess . StartInfo . CreateNoWindow = this . HideCommandPromptWindow ;
272-
273- DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs ( driverServiceProcess . StartInfo ) ;
274- this . OnDriverProcessStarting ( eventArgs ) ;
275-
276- driverServiceProcess . Start ( ) ;
277- }
278- catch
279- {
280- driverServiceProcess . Dispose ( ) ;
281- throw ;
281+ this . driverServiceProcess = driverServiceProcess ;
282282 }
283-
284- this . driverServiceProcess = driverServiceProcess ;
285283 }
286284 }
287285
0 commit comments