private void Initialize() { if (!this.disposed) { if (this.serviceProvider == IntPtr.Zero) { lock (this.serviceProviderStateLock) { if (!this.disposed && this.serviceProvider == IntPtr.Zero) { uint errorCode = ServiceInteropWrapper.CreateServiceProvider( this.queryengineConfiguration, out this.serviceProvider); Exception exception = Marshal.GetExceptionForHR((int)errorCode); if (exception != null) { throw exception; } } } } } else { throw new ObjectDisposedException(typeof(QueryPartitionProvider).Name); } }
internal static TryCatch <IntPtr> TryCreateServiceProvider(string queryEngineConfiguration) { try { IntPtr serviceProvider = IntPtr.Zero; uint errorCode = ServiceInteropWrapper.CreateServiceProvider( queryEngineConfiguration, out serviceProvider); Exception exception = Marshal.GetExceptionForHR((int)errorCode); if (exception != null) { DefaultTrace.TraceWarning("QueryPartitionProvider.TryCreateServiceProvider failed with exception {0}", exception); return(TryCatch <IntPtr> .FromException(exception)); } return(TryCatch <IntPtr> .FromResult(serviceProvider)); } catch (Exception ex) { DefaultTrace.TraceWarning("QueryPartitionProvider.TryCreateServiceProvider failed with exception {0}", ex); return(TryCatch <IntPtr> .FromException(ex)); } }