Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MessageQueue.cs
- dtdvalidator.cs
- Line.cs
- Pool.cs
- HwndSource.cs
- Rotation3DKeyFrameCollection.cs
- ArrayEditor.cs
- MulticastOption.cs
- SchemaName.cs
- ControlCachePolicy.cs
- StructuredTypeEmitter.cs
- OleDbMetaDataFactory.cs
- DocumentViewerConstants.cs
- ProgressChangedEventArgs.cs
- ListBindableAttribute.cs
- MemoryStream.cs
- ChtmlTextWriter.cs
- DLinqDataModelProvider.cs
- SamlAdvice.cs
- SAPIEngineTypes.cs
- HttpValueCollection.cs
- CodeEventReferenceExpression.cs
- UTF7Encoding.cs
- Dump.cs
- WindowCollection.cs
- SafeNativeMethodsOther.cs
- PerformanceCounterManager.cs
- StorageAssociationTypeMapping.cs
- EnumerableRowCollectionExtensions.cs
- FixedPageProcessor.cs
- LambdaCompiler.ControlFlow.cs
- InternalDispatchObject.cs
- PhysicalAddress.cs
- VersionPair.cs
- ServiceOperation.cs
- TouchPoint.cs
- SqlProcedureAttribute.cs
- Window.cs
- ClientSettingsStore.cs
- DataKeyCollection.cs
- UnmanagedMemoryStream.cs
- TrimSurroundingWhitespaceAttribute.cs
- TreeViewEvent.cs
- WorkItem.cs
- ListViewGroupItemCollection.cs
- EventProvider.cs
- ToolStripDropDownButton.cs
- FontStretch.cs
- SoapElementAttribute.cs
- ButtonField.cs
- MeasureItemEvent.cs
- SoapExtensionImporter.cs
- SchemaAttDef.cs
- DrawingVisual.cs
- WebContext.cs
- Bezier.cs
- Permission.cs
- GridSplitter.cs
- SwitchAttribute.cs
- formatter.cs
- RelationalExpressions.cs
- FullTrustAssembly.cs
- OutputCacheEntry.cs
- MessageQueue.cs
- DocumentViewer.cs
- DataGridViewTextBoxEditingControl.cs
- EmissiveMaterial.cs
- ReadWriteObjectLock.cs
- DesignerFrame.cs
- Constraint.cs
- UnsafeNativeMethods.cs
- InfiniteIntConverter.cs
- XmlHierarchicalEnumerable.cs
- NetDataContractSerializer.cs
- Random.cs
- PseudoWebRequest.cs
- SafeProcessHandle.cs
- HtmlTableCell.cs
- TextEndOfParagraph.cs
- DefaultAsyncDataDispatcher.cs
- IHttpResponseInternal.cs
- ScriptManager.cs
- AudioFormatConverter.cs
- MergePropertyDescriptor.cs
- NamedPermissionSet.cs
- HttpWebRequestElement.cs
- Formatter.cs
- ChannelServices.cs
- HtmlTextArea.cs
- InvalidFilterCriteriaException.cs
- Iis7Helper.cs
- ClientUtils.cs
- DataGridViewCellParsingEventArgs.cs
- ADConnectionHelper.cs
- ConfigurationManagerHelper.cs
- InvalidCommandTreeException.cs
- FacetDescriptionElement.cs
- CommandConverter.cs
- NamespaceEmitter.cs
- WebInvokeAttribute.cs