Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / EventRouteFactory.cs / 1 / EventRouteFactory.cs
using System; using System.Windows; using MS.Utility; namespace System.Windows { ////// Creates and recycles instance of EventRoute /// internal static class EventRouteFactory { #region Operations ////// Fetch a recycled object if available /// else create a new instance /// internal static EventRoute FetchObject(RoutedEvent routedEvent) { EventRoute eventRoute = Pop(); if (eventRoute == null) { eventRoute = new EventRoute(routedEvent); } else { eventRoute.RoutedEvent = routedEvent; } return eventRoute; } ////// Recycle the given instance of EventRoute /// internal static void RecycleObject(EventRoute eventRoute) { // Cleanup all refernces held eventRoute.Clear(); // Push instance on to the stack Push(eventRoute); } #endregion Operations #region HelperMethods ////// Push the given instance of EventRoute on to the stack /// private static void Push(EventRoute eventRoute) { lock (_synchronized) { // In a normal scenario it is extremely rare to // require more than 2 EventRoutes at the same time if (_eventRouteStack == null) { _eventRouteStack = new EventRoute[2]; _stackTop = 0; } if (_stackTop < 2) { _eventRouteStack[_stackTop++] = eventRoute; } } } ////// Pop off the last instance of EventRoute in the stack /// private static EventRoute Pop() { lock (_synchronized) { if (_stackTop > 0) { EventRoute eventRoute = _eventRouteStack[--_stackTop]; _eventRouteStack[_stackTop] = null; return eventRoute; } } return null; } #endregion HelperMethods #region Data private static EventRoute[] _eventRouteStack; private static int _stackTop; private static object _synchronized = new object(); #endregion Data } } // 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
- RegexCode.cs
- OptimizerPatterns.cs
- InstanceBehavior.cs
- SqlUtil.cs
- DataViewSetting.cs
- EntitySet.cs
- PasswordTextNavigator.cs
- SessionStateContainer.cs
- VersionConverter.cs
- XPathAncestorQuery.cs
- EdmItemCollection.cs
- ClientTargetCollection.cs
- SynchronizationContext.cs
- TreeBuilder.cs
- HttpListenerRequestUriBuilder.cs
- HttpWebResponse.cs
- CatalogUtil.cs
- SystemNetHelpers.cs
- ReliableOutputSessionChannel.cs
- AuthenticationServiceManager.cs
- SecurityKeyIdentifier.cs
- IUnknownConstantAttribute.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- SoapCodeExporter.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- DragAssistanceManager.cs
- ValidationErrorInfo.cs
- MouseDevice.cs
- SpeechAudioFormatInfo.cs
- FixedSOMTableRow.cs
- Column.cs
- XhtmlBasicLiteralTextAdapter.cs
- FileStream.cs
- XmlObjectSerializerWriteContextComplex.cs
- SqlNodeTypeOperators.cs
- AuthenticateEventArgs.cs
- BinaryMessageEncodingElement.cs
- DbExpressionRules.cs
- ToolStripScrollButton.cs
- HttpPostedFile.cs
- HuffCodec.cs
- SoapInteropTypes.cs
- DataGridAutomationPeer.cs
- GeneralTransform3D.cs
- RectangleGeometry.cs
- ValidatingReaderNodeData.cs
- SessionIDManager.cs
- ReflectTypeDescriptionProvider.cs
- LogicalCallContext.cs
- CurrentChangedEventManager.cs
- QilPatternFactory.cs
- TrustManager.cs
- DataService.cs
- Span.cs
- HorizontalAlignConverter.cs
- ResourcesChangeInfo.cs
- MessageAction.cs
- XmlBaseReader.cs
- SqlComparer.cs
- FontUnit.cs
- ReferentialConstraint.cs
- SignatureToken.cs
- PropertySourceInfo.cs
- DBParameter.cs
- StdValidatorsAndConverters.cs
- ProcessProtocolHandler.cs
- DataGridViewRowPrePaintEventArgs.cs
- SrgsElement.cs
- ModifierKeysConverter.cs
- PrimaryKeyTypeConverter.cs
- Gdiplus.cs
- Line.cs
- HtmlInputText.cs
- SafeUserTokenHandle.cs
- TextBreakpoint.cs
- ProviderCommandInfoUtils.cs
- Dictionary.cs
- ImageCodecInfoPrivate.cs
- SystemIcons.cs
- InvokeGenerator.cs
- SettingsProviderCollection.cs
- TagPrefixCollection.cs
- SettingsAttributes.cs
- ContainsRowNumberChecker.cs
- InsufficientMemoryException.cs
- WinEventQueueItem.cs
- ExceptionTranslationTable.cs
- XamlInt32CollectionSerializer.cs
- BitmapEffectCollection.cs
- Authorization.cs
- PtsCache.cs
- PropertyStore.cs
- TableLayoutSettings.cs
- EdmProviderManifest.cs
- AuthorizationRuleCollection.cs
- DataRowView.cs
- GC.cs
- ExceptionCollection.cs
- MessageSmuggler.cs
- ValidationResult.cs