Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / UIAgentMonitor.cs / 1 / UIAgentMonitor.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // // Presharp uses the c# pragma mechanism to supress its warnings. // These are not recognised by the base compiler so we need to explictly // disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp // for details. // #pragma warning disable 1634, 1691 // unknown message, unknown pragma namespace Microsoft.InfoCards { using System; using System.Collections.Generic; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // This class is used to make certain that only one user call and only one client per TS session can // use the infocard system. // class UIAgentMonitor { static UIAgentMonitor s_singleton = null; static object s_syncRoot = new object(); // // Dictionary of currently running users. // Dictionarym_currentCallingUsers; // user name to request dictionary. Dictionary m_currentTSSessions; // tssession to request dictionary. private UIAgentMonitor() { m_currentCallingUsers = new Dictionary (); m_currentTSSessions = new Dictionary (); } // // Summary // Returns the singleton instance of the monitor, creating it if necessary. // static public UIAgentMonitor Instance() { // // Has it been created yet? // if ( null == s_singleton ) { // // Doesn't look like it try for the lock. // lock ( s_syncRoot ) { // // Was this the first thread to get the lock? // if ( null == s_singleton ) { // // Yes, this thread needs to create the monitor. // s_singleton = new UIAgentMonitor(); } } } return s_singleton; } // // Summary // Adds a new UIAgentMonitorHandle to the collection if the user and tssession associated with the request // are not already occupied. If they are then this method throws the ServiceBusyException. // // Parameters // request - The request to add. // public void AddNewClient( UIAgentMonitorHandle handle ) { lock ( s_syncRoot ) { string user = handle.UserName; int tssession = handle.TsSessionId; if ( m_currentCallingUsers.ContainsKey( user ) ) { throw IDT.ThrowHelperError( new ServiceBusyException( SR.GetString( SR.ServiceInUseOnAnotherSession ) ) ); } if ( m_currentTSSessions.ContainsKey( tssession ) ) { throw IDT.ThrowHelperError( new ServiceBusyException( SR.GetString( SR.ServiceInUseOnAnotherSession ) ) ); } m_currentCallingUsers.Add( user, handle ); try { m_currentTSSessions.Add( tssession, handle ); } catch( Exception ) { m_currentCallingUsers.Remove( user ); throw; } } } // // Summary // Removes a UIAgentMonitorHandle from the collection if this specific request is in the collection. // // Parameters // request - the request to remove. // public void RemoveClient( UIAgentMonitorHandle handle ) { lock ( s_syncRoot ) { string user = handle.UserName; int tssession = handle.TsSessionId; if ( ( !string.IsNullOrEmpty( user ) ) && ( m_currentCallingUsers.ContainsKey( user ) ) && ( handle == m_currentCallingUsers[ user ] ) ) { m_currentCallingUsers.Remove( user ); } if ( ( m_currentTSSessions.ContainsKey( tssession ) ) && ( handle == m_currentTSSessions[ tssession ] ) ) { m_currentTSSessions.Remove( tssession ); } } } } } // 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
- IPGlobalProperties.cs
- DbSource.cs
- WebProxyScriptElement.cs
- BadImageFormatException.cs
- MonthCalendar.cs
- StorageScalarPropertyMapping.cs
- SQLDateTime.cs
- HotSpotCollection.cs
- ReadOnlyHierarchicalDataSource.cs
- WebFaultClientMessageInspector.cs
- DataGridViewCellPaintingEventArgs.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- ImmutableCollection.cs
- ThousandthOfEmRealPoints.cs
- XmlAtomErrorReader.cs
- XmlDownloadManager.cs
- MiniModule.cs
- WebBodyFormatMessageProperty.cs
- precedingquery.cs
- PropertyIDSet.cs
- WebPartEditorCancelVerb.cs
- SuppressIldasmAttribute.cs
- ToolStripButton.cs
- UndoEngine.cs
- CodePrimitiveExpression.cs
- WindowsRebar.cs
- DoubleAnimation.cs
- HTMLTagNameToTypeMapper.cs
- DataGridViewColumnEventArgs.cs
- EllipseGeometry.cs
- SessionStateItemCollection.cs
- WebBrowserProgressChangedEventHandler.cs
- Semaphore.cs
- _IPv6Address.cs
- ComponentConverter.cs
- TableLayoutPanel.cs
- WorkflowApplicationTerminatedException.cs
- ObjectItemAttributeAssemblyLoader.cs
- ResXResourceSet.cs
- CngProperty.cs
- KeyGestureValueSerializer.cs
- TransformCryptoHandle.cs
- OneWayBindingElement.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- httpserverutility.cs
- WebControlsSection.cs
- XPathNodeList.cs
- StringArrayConverter.cs
- ApplicationId.cs
- WorkflowPersistenceContext.cs
- Label.cs
- WebZone.cs
- DispatchWrapper.cs
- ForwardPositionQuery.cs
- PathParser.cs
- sqlmetadatafactory.cs
- EntityDataSourceUtil.cs
- ReflectPropertyDescriptor.cs
- SineEase.cs
- X509SecurityTokenAuthenticator.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- SystemTcpConnection.cs
- ModuleBuilder.cs
- Base64Stream.cs
- TextBox.cs
- GacUtil.cs
- TableRowCollection.cs
- DesignerAttribute.cs
- ScriptResourceAttribute.cs
- HashHelper.cs
- FormatVersion.cs
- AdRotator.cs
- RelationshipDetailsCollection.cs
- XmlDataSource.cs
- Guid.cs
- Bits.cs
- TextElementCollectionHelper.cs
- TextSpanModifier.cs
- DomNameTable.cs
- BindingSourceDesigner.cs
- TraceEventCache.cs
- CodeIdentifiers.cs
- DesignerResources.cs
- EnvelopedSignatureTransform.cs
- DataGridViewRowPostPaintEventArgs.cs
- AliasExpr.cs
- ControlParameter.cs
- QueryableFilterRepeater.cs
- AssemblyBuilderData.cs
- HwndTarget.cs
- DeclarativeCatalogPart.cs
- XPathNavigatorKeyComparer.cs
- HttpRuntime.cs
- SystemFonts.cs
- SafeThemeHandle.cs
- CommentAction.cs
- SessionStateContainer.cs
- WorkflowRuntimeServiceElementCollection.cs
- CompilerErrorCollection.cs
- PropertyDescriptorGridEntry.cs