Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / ManagedLibraries / Remoting / Channels / CORE / BasicAsyncResult.cs / 1305376 / BasicAsyncResult.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** File: BasicAsyncResult.cs ** ** Purpose: Base class for async result implementations. ** ** Date: Oct 21, 2001 ** ===========================================================*/ using System; using System.Threading; namespace System.Runtime.Remoting.Channels { internal class BasicAsyncResult : IAsyncResult { private AsyncCallback _asyncCallback; private Object _asyncState; private Object _returnValue; private Exception _exception; private bool _bIsComplete; private ManualResetEvent _manualResetEvent; internal BasicAsyncResult(AsyncCallback callback, Object state) { _asyncCallback = callback; _asyncState = state; } // BasicAsyncResult public Object AsyncState { get { return _asyncState; } } // AsyncState public WaitHandle AsyncWaitHandle { get { bool bSavedIsComplete = _bIsComplete; if (_manualResetEvent == null) { lock (this) { if (_manualResetEvent == null) { _manualResetEvent = new ManualResetEvent(bSavedIsComplete); } } } if (!bSavedIsComplete && _bIsComplete) _manualResetEvent.Set(); return (WaitHandle)_manualResetEvent; } } // AsyncWaitHandle public bool CompletedSynchronously { get { return false; } } // CompletedSynchronously public bool IsCompleted { get { return _bIsComplete; } } // IsCompleted internal Exception Exception { get { return _exception; } } internal void SetComplete(Object returnValue, Exception exception) { _returnValue = returnValue; _exception = exception; CleanupOnComplete(); _bIsComplete = true; try { if (_manualResetEvent != null) _manualResetEvent.Set(); } catch (Exception e) { if (_exception == null) _exception = e; } // invoke the callback if (_asyncCallback != null) _asyncCallback(this); } // SetComplete internal virtual void CleanupOnComplete() { } } // BasicAsyncResult } // namespace System.Runtime.Remoting.Channels // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** File: BasicAsyncResult.cs ** ** Purpose: Base class for async result implementations. ** ** Date: Oct 21, 2001 ** ===========================================================*/ using System; using System.Threading; namespace System.Runtime.Remoting.Channels { internal class BasicAsyncResult : IAsyncResult { private AsyncCallback _asyncCallback; private Object _asyncState; private Object _returnValue; private Exception _exception; private bool _bIsComplete; private ManualResetEvent _manualResetEvent; internal BasicAsyncResult(AsyncCallback callback, Object state) { _asyncCallback = callback; _asyncState = state; } // BasicAsyncResult public Object AsyncState { get { return _asyncState; } } // AsyncState public WaitHandle AsyncWaitHandle { get { bool bSavedIsComplete = _bIsComplete; if (_manualResetEvent == null) { lock (this) { if (_manualResetEvent == null) { _manualResetEvent = new ManualResetEvent(bSavedIsComplete); } } } if (!bSavedIsComplete && _bIsComplete) _manualResetEvent.Set(); return (WaitHandle)_manualResetEvent; } } // AsyncWaitHandle public bool CompletedSynchronously { get { return false; } } // CompletedSynchronously public bool IsCompleted { get { return _bIsComplete; } } // IsCompleted internal Exception Exception { get { return _exception; } } internal void SetComplete(Object returnValue, Exception exception) { _returnValue = returnValue; _exception = exception; CleanupOnComplete(); _bIsComplete = true; try { if (_manualResetEvent != null) _manualResetEvent.Set(); } catch (Exception e) { if (_exception == null) _exception = e; } // invoke the callback if (_asyncCallback != null) _asyncCallback(this); } // SetComplete internal virtual void CleanupOnComplete() { } } // BasicAsyncResult } // namespace System.Runtime.Remoting.Channels // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RtfNavigator.cs
- XmlReaderDelegator.cs
- Int32CollectionValueSerializer.cs
- TemplateGroupCollection.cs
- Identifier.cs
- DesignerOptions.cs
- DropDownList.cs
- ByteStream.cs
- CultureTableRecord.cs
- WebBrowser.cs
- ImageDesigner.cs
- InputMethod.cs
- ping.cs
- LinqDataSourceContextEventArgs.cs
- DoubleLinkListEnumerator.cs
- IssuanceTokenProviderState.cs
- PermissionToken.cs
- Frame.cs
- SafeArchiveContext.cs
- DoubleStorage.cs
- SimpleExpression.cs
- FixedSOMLineRanges.cs
- ValueTable.cs
- HttpWriter.cs
- FramingFormat.cs
- ResolveMatchesCD1.cs
- TextEffect.cs
- ArgumentException.cs
- ScrollableControl.cs
- WindowsUpDown.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- EntityDataSourceWrapperCollection.cs
- VideoDrawing.cs
- EntityClientCacheEntry.cs
- X509ThumbprintKeyIdentifierClause.cs
- ArraySegment.cs
- IDispatchConstantAttribute.cs
- SubclassTypeValidatorAttribute.cs
- ScrollViewerAutomationPeer.cs
- BrowserTree.cs
- MenuItem.cs
- Stroke.cs
- StreamGeometry.cs
- XmlSerializerFactory.cs
- TemplateDefinition.cs
- Package.cs
- XmlBoundElement.cs
- ListViewGroupItemCollection.cs
- ClientBuildManager.cs
- InputScopeAttribute.cs
- httpserverutility.cs
- RegexCode.cs
- FontStretch.cs
- LineInfo.cs
- SecurityUniqueId.cs
- CrossContextChannel.cs
- SimpleFileLog.cs
- QueryableDataSourceHelper.cs
- ComplexBindingPropertiesAttribute.cs
- PathTooLongException.cs
- InputReferenceExpression.cs
- UrlMapping.cs
- GenericIdentity.cs
- StrongNameUtility.cs
- NativeMethods.cs
- DesignerOptionService.cs
- TypeElementCollection.cs
- SystemInfo.cs
- XmlSchemaAnnotated.cs
- BatchServiceHost.cs
- OdbcInfoMessageEvent.cs
- FormsAuthenticationEventArgs.cs
- RemotingClientProxy.cs
- DataGridRelationshipRow.cs
- MenuItemStyle.cs
- EventSinkActivity.cs
- DetailsView.cs
- InvalidAsynchronousStateException.cs
- TextBoxBase.cs
- ISFClipboardData.cs
- SecurityResources.cs
- OuterGlowBitmapEffect.cs
- WebServiceErrorEvent.cs
- DependencyObjectCodeDomSerializer.cs
- Reference.cs
- InstanceCreationEditor.cs
- HttpModuleAction.cs
- CodeIdentifiers.cs
- SqlDataAdapter.cs
- ValueQuery.cs
- glyphs.cs
- Control.cs
- InputLangChangeRequestEvent.cs
- HttpFileCollection.cs
- PlainXmlWriter.cs
- ScrollChrome.cs
- DbConnectionStringCommon.cs
- ToggleProviderWrapper.cs
- ToolStripPanelRow.cs
- ReaderWriterLockWrapper.cs