Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / UIAgentAsyncEndRequest.cs / 1 / UIAgentAsyncEndRequest.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Collections; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; using System.IO; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // Base class for all Async Completation requests from the UI Agent. // !!!!!! Subclasses should not override OnMarshalOutArgs. !!!!!!! // internal abstract class UIAgentAsyncEndRequest : UIAgentRequest { int m_asyncHandle; bool m_isCompleted; object m_result; bool m_isCancelled; // // Summary: // Creates an new UIAgentAsyncEndRequest // // Arguments: // rpcHandle: The RPC Context handle. // inArgs: The stream to hold the input arguments // outArgs: The stream to hold the output arguments // parent: the parent UI Request // public UIAgentAsyncEndRequest( IntPtr rpcHandle, Stream inArgs, Stream outArgs, ClientUIRequest parent ) : base( rpcHandle, inArgs, outArgs, parent ) { } public object Result { get { IDT.Assert( true == m_isCompleted, "Attempt to pick up async result before completion." ); return m_result; } } public bool IsCancelled { get { IDT.Assert( true == m_isCompleted, "Attempt to pick up async result before completion." ); return m_isCancelled; } } // // Summary: // Read any inbound arguments. // // Remarks: // read the async context handle we send at the end of the Begin call. // protected override void OnMarshalInArgs() { BinaryReader breader = new InfoCardBinaryReader( InArgs, Encoding.Unicode ); m_asyncHandle = breader.ReadInt32(); IDT.Assert( 0 != m_asyncHandle, "null async handle" ); } // // Summary: // Process the request, and wait for the async operation to complete or be canceled. // protected override void OnProcess() { // // Look up this Async operation on the parent request and wait for completion. Return any errors by // throwing the exception. // // // In current implementation, if WaitForAsyncCompletion throws an exception // then no asyncResult is returned, so it is not disposed off by the using statement. // using ( RpcAsyncResult asyncResult = ParentRequest.WaitForAsyncCompletion( m_asyncHandle ) ) { m_isCancelled = asyncResult.IsCanceled; if ( !m_isCancelled ) { m_result = asyncResult.Result; } } m_isCompleted = true; } // // Summary: // This method determines whether the operation was cancelled or not, writes the appropriate indicator, and // then calls OnMarshalAsyncOutArgs if appropriate. // protected sealed override void OnMarshalOutArgs() { BinaryWriter writer = new BinaryWriter( OutArgs, Encoding.Unicode ); writer.Write( IsCancelled ); if ( !IsCancelled ) { OnMarshalAsyncOutArgs( writer ); } } // // Summary: // This is called if the Async operation is not cancelled. // protected virtual void OnMarshalAsyncOutArgs( BinaryWriter writer ) { // // Default is to do nothing. // } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlMtomWriter.cs
- VerificationAttribute.cs
- ImageAutomationPeer.cs
- OracleConnectionFactory.cs
- ColumnHeaderConverter.cs
- SmtpFailedRecipientsException.cs
- WebProxyScriptElement.cs
- SelectedGridItemChangedEvent.cs
- MaskedTextProvider.cs
- BinaryObjectReader.cs
- ListViewSortEventArgs.cs
- UpdatePanelControlTrigger.cs
- BmpBitmapDecoder.cs
- Char.cs
- Memoizer.cs
- BulletChrome.cs
- DeclarativeCatalogPart.cs
- XmlQualifiedNameTest.cs
- PropertyEmitterBase.cs
- RootBrowserWindowAutomationPeer.cs
- ControlOperationBehavior.cs
- PropertyGrid.cs
- BinaryParser.cs
- SiteMapDataSourceView.cs
- ToolBar.cs
- IsolatedStorage.cs
- DocumentViewerAutomationPeer.cs
- Permission.cs
- TrackingProfileDeserializationException.cs
- NumericExpr.cs
- FunctionParameter.cs
- BaseProcessProtocolHandler.cs
- BaseServiceProvider.cs
- shaper.cs
- ConfigurationManagerHelper.cs
- HttpPostedFile.cs
- DataGridViewCellStyleConverter.cs
- StatusBarPanelClickEvent.cs
- SamlSubjectStatement.cs
- Transaction.cs
- SystemResources.cs
- GlyphCache.cs
- ViewManager.cs
- ButtonBaseAutomationPeer.cs
- MouseCaptureWithinProperty.cs
- AppDomainShutdownMonitor.cs
- XmlSchemaObject.cs
- HtmlTableCell.cs
- AsymmetricKeyExchangeDeformatter.cs
- OutputCacheModule.cs
- ButtonField.cs
- AccessDataSourceView.cs
- HostingEnvironmentException.cs
- TrackBarRenderer.cs
- SqlCacheDependencyDatabase.cs
- ObjectIDGenerator.cs
- IntegrationExceptionEventArgs.cs
- XmlNullResolver.cs
- HttpCapabilitiesBase.cs
- XmlSchemaAttributeGroup.cs
- oledbmetadatacollectionnames.cs
- SystemNetHelpers.cs
- TextTreeInsertElementUndoUnit.cs
- XPathNavigator.cs
- IndividualDeviceConfig.cs
- GeometryModel3D.cs
- FreeIndexList.cs
- CommandLineParser.cs
- SqlDataSourceCache.cs
- PeerToPeerException.cs
- OracleColumn.cs
- AncestorChangedEventArgs.cs
- PrimitiveXmlSerializers.cs
- MinMaxParagraphWidth.cs
- ComplexPropertyEntry.cs
- PageContentCollection.cs
- HWStack.cs
- CodeValidator.cs
- SqlConnectionPoolProviderInfo.cs
- ItemContainerGenerator.cs
- WithStatement.cs
- DynamicDataExtensions.cs
- CallSite.cs
- ConstraintEnumerator.cs
- DescendantBaseQuery.cs
- DbConnectionPoolGroup.cs
- SymbolDocumentGenerator.cs
- ContainerUIElement3D.cs
- PeerInvitationResponse.cs
- RenderingEventArgs.cs
- XmlSerializationWriter.cs
- CommandDevice.cs
- AppLevelCompilationSectionCache.cs
- TextElement.cs
- elementinformation.cs
- UnsafeNativeMethods.cs
- DateTimeOffsetAdapter.cs
- FollowerQueueCreator.cs
- BamlBinaryReader.cs
- IpcServerChannel.cs