/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriverServer"/> class. /// </summary> public InternetExplorerDriverServer() { // Only one copy of the native code library should be loaded into // the process at any given time. if (!LibraryIsLoaded) { this.ExtractNativeLibrary(); library = new NativeLibrary(this.nativeLibraryPath); } }
/// <summary> /// Releases all resources used by this InternetExplorerDriverServer. /// </summary> /// <param name="disposing"><see langword="true"/> to dispose of managed and unmanaged resources; /// <see langword="false"/> to only dispose of unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing) { if (LibraryIsLoaded && IsRunning) { GetServerSessionCountFunction getSessionCountFunction = library.GetUnmanagedFunction(GetServerSessionCountFunctionName, typeof(GetServerSessionCountFunction)) as GetServerSessionCountFunction; if (getSessionCountFunction != null) { int sessionCount = getSessionCountFunction(); if (sessionCount == 0) { StopServerFunction stopFunction = library.GetUnmanagedFunction(StopServerFunctionName, typeof(StopServerFunction)) as StopServerFunction; if (stopFunction != null) { stopFunction(this.serverHandle); this.serverHandle = IntPtr.Zero; } library.Dispose(); library = null; this.DeleteLibraryDirectory(); } } } } }