예제 #1
0
		public CimAsyncStatus CloseAsync()
		{
			IObservable<object> cimAsyncDelegatedObservable = new CimAsyncDelegatedObservable<object>((IObserver<object> observer) => {
				bool flag;
				lock (this._disposeThreadSafetyLock)
				{
					flag = this._disposed;
					this._disposed = true;
				}
				if (!flag)
				{
					CimSession.CloseAsyncImpersonationWorker closeAsyncImpersonationWorker = new CimSession.CloseAsyncImpersonationWorker(observer);
					MiResult miResult = this._handle.ReleaseHandleAsynchronously(new SessionHandle.OnSessionHandleReleasedDelegate(closeAsyncImpersonationWorker.OnCompleted));
					CimException exceptionIfMiResultFailure = CimException.GetExceptionIfMiResultFailure(miResult, null, null);
					if (exceptionIfMiResultFailure != null)
					{
						observer.OnError(exceptionIfMiResultFailure);
						closeAsyncImpersonationWorker.Dispose();
					}
					return;
				}
				else
				{
					observer.OnCompleted();
					return;
				}
			}
			);
			return new CimAsyncStatus(cimAsyncDelegatedObservable);
		}
예제 #2
0
		public static CimAsyncResult<CimSession> CreateAsync(string computerName, CimSessionOptions sessionOptions)
		{
			IObservable<CimSession> cimAsyncDelegatedObservable = new CimAsyncDelegatedObservable<CimSession>((IObserver<CimSession> observer) => {
				CimSession cimSession = null;
				try
				{
					cimSession = CimSession.Create(computerName, sessionOptions);
				}
				catch (Exception exception1)
				{
					Exception exception = exception1;
					observer.OnError(exception);
				}
				observer.OnNext(cimSession);
				observer.OnCompleted();
			}
			);
			return new CimAsyncResult<CimSession>(cimAsyncDelegatedObservable);
		}