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
- ControlOperationBehavior.cs
- XmlHelper.cs
- DataGridItemCollection.cs
- AuthenticateEventArgs.cs
- OleDbConnection.cs
- DiscoveryDocumentReference.cs
- CircleHotSpot.cs
- OdbcCommandBuilder.cs
- SoapObjectWriter.cs
- XmlNullResolver.cs
- RegexCompilationInfo.cs
- PenContexts.cs
- Accessible.cs
- ExecutorLocksHeldException.cs
- XmlSchemaExporter.cs
- PropertyGridEditorPart.cs
- BuildProviderUtils.cs
- DataException.cs
- MenuItemStyleCollection.cs
- StructuredType.cs
- InvalidWMPVersionException.cs
- EntityDataSourceState.cs
- EventDescriptor.cs
- ArgumentException.cs
- SqlVersion.cs
- ResourceDictionary.cs
- Propagator.cs
- Slider.cs
- BinaryFormatter.cs
- XmlElementAttribute.cs
- WindowsTreeView.cs
- FieldNameLookup.cs
- ScrollProperties.cs
- ChannelManager.cs
- TextBox.cs
- WmlObjectListAdapter.cs
- BinaryEditor.cs
- XmlSchemas.cs
- ConcurrentBag.cs
- XmlSchemaAttributeGroup.cs
- DesignBindingValueUIHandler.cs
- WorkflowRuntimeServiceElementCollection.cs
- RoleManagerEventArgs.cs
- XamlToRtfWriter.cs
- ClientRuntimeConfig.cs
- SHA1Managed.cs
- IISUnsafeMethods.cs
- WindowsSolidBrush.cs
- FastPropertyAccessor.cs
- TextClipboardData.cs
- Composition.cs
- MemberInfoSerializationHolder.cs
- SqlRewriteScalarSubqueries.cs
- DataChangedEventManager.cs
- recordstate.cs
- DesignerValidatorAdapter.cs
- Matrix.cs
- MdiWindowListStrip.cs
- ImageUrlEditor.cs
- BitmapData.cs
- RequiredAttributeAttribute.cs
- EntityUtil.cs
- FormViewRow.cs
- CatalogZoneBase.cs
- AsyncCompletedEventArgs.cs
- QilParameter.cs
- ProgressBarBrushConverter.cs
- SqlExpander.cs
- SafeFileMappingHandle.cs
- SmtpMail.cs
- FileSystemInfo.cs
- AnimationException.cs
- WmlListAdapter.cs
- AutoScrollHelper.cs
- XmlStreamStore.cs
- _FtpDataStream.cs
- PropertyDescriptor.cs
- TransformPattern.cs
- FullTextLine.cs
- OLEDB_Enum.cs
- ParamArrayAttribute.cs
- PasswordPropertyTextAttribute.cs
- XmlUtil.cs
- DataRecord.cs
- CodeMemberMethod.cs
- DomainUpDown.cs
- UriExt.cs
- UriSection.cs
- UIElementParagraph.cs
- ObjectCloneHelper.cs
- ApplicationServiceHelper.cs
- UidManager.cs
- Executor.cs
- HwndTarget.cs
- DefaultValueConverter.cs
- SharedPersonalizationStateInfo.cs
- ConnectorMovedEventArgs.cs
- StateManagedCollection.cs
- FormClosedEvent.cs
- HtmlElementErrorEventArgs.cs