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
- CodeGroup.cs
- Socket.cs
- CompiledXpathExpr.cs
- SerializableAttribute.cs
- HashSet.cs
- TextRunCacheImp.cs
- SystemDiagnosticsSection.cs
- ResolvePPIDRequest.cs
- JapaneseCalendar.cs
- TraceRecord.cs
- SiteMembershipCondition.cs
- _CookieModule.cs
- CatalogPartCollection.cs
- FormsAuthenticationCredentials.cs
- XsltQilFactory.cs
- CheckBoxRenderer.cs
- CustomAttributeFormatException.cs
- SqlDeflator.cs
- FunctionCommandText.cs
- DynamicActivityXamlReader.cs
- MatrixCamera.cs
- Vector3DValueSerializer.cs
- IconBitmapDecoder.cs
- serverconfig.cs
- WebColorConverter.cs
- SmiConnection.cs
- ApplyTemplatesAction.cs
- ToolStripOverflowButton.cs
- SignatureGenerator.cs
- ContextDataSourceView.cs
- _CacheStreams.cs
- AddInStore.cs
- FixUp.cs
- OracleTransaction.cs
- WebMessageEncoderFactory.cs
- ConstraintConverter.cs
- SoapServerProtocol.cs
- ShaderEffect.cs
- HijriCalendar.cs
- HandlerBase.cs
- DrawingBrush.cs
- FormView.cs
- MessageEventSubscriptionService.cs
- VirtualDirectoryMappingCollection.cs
- DbProviderFactory.cs
- Token.cs
- Control.cs
- GridViewCommandEventArgs.cs
- GenericAuthenticationEventArgs.cs
- SHA384.cs
- Tuple.cs
- IODescriptionAttribute.cs
- ContainerParaClient.cs
- HostProtectionPermission.cs
- RotationValidation.cs
- TextBlockAutomationPeer.cs
- SplitterPanel.cs
- Page.cs
- Event.cs
- ReturnEventArgs.cs
- ListMarkerSourceInfo.cs
- DecoderExceptionFallback.cs
- ToolStripPanelCell.cs
- HttpModuleCollection.cs
- ListViewCancelEventArgs.cs
- DefaultHttpHandler.cs
- GeometryDrawing.cs
- CommandEventArgs.cs
- CacheSection.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- BitmapCodecInfo.cs
- WebControlParameterProxy.cs
- SmiEventStream.cs
- DiffuseMaterial.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- Effect.cs
- Control.cs
- PageAdapter.cs
- sqlmetadatafactory.cs
- Event.cs
- UnknownBitmapDecoder.cs
- SuppressMessageAttribute.cs
- hresults.cs
- SspiNegotiationTokenProvider.cs
- ProtectedConfigurationSection.cs
- ListControl.cs
- InternalConfigSettingsFactory.cs
- Font.cs
- HybridCollection.cs
- RemoteWebConfigurationHost.cs
- VersionConverter.cs
- RtfFormatStack.cs
- SchemaInfo.cs
- ObjectResult.cs
- AlternateViewCollection.cs
- PageRequestManager.cs
- BinaryFormatterWriter.cs
- HtmlShim.cs
- ListControlDesigner.cs
- InputBinder.cs