Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / EventRouteFactory.cs / 1305600 / 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
- SystemBrushes.cs
- HttpUnhandledOperationInvoker.cs
- GeometryModel3D.cs
- SelectorItemAutomationPeer.cs
- MatrixCamera.cs
- LOSFormatter.cs
- TakeQueryOptionExpression.cs
- CodeBinaryOperatorExpression.cs
- MsmqIntegrationChannelListener.cs
- EventSinkHelperWriter.cs
- AVElementHelper.cs
- MimePart.cs
- IRCollection.cs
- HotSpotCollection.cs
- BuildResult.cs
- WinFormsSecurity.cs
- NativeObjectSecurity.cs
- ToolStripControlHost.cs
- PhonemeConverter.cs
- CalloutQueueItem.cs
- TextEffectCollection.cs
- DoubleCollectionConverter.cs
- SessionStateItemCollection.cs
- SymbolEqualComparer.cs
- PrincipalPermission.cs
- DropTarget.cs
- DockProviderWrapper.cs
- SafeHandle.cs
- CacheMemory.cs
- OleDbError.cs
- AppSettingsExpressionBuilder.cs
- FragmentQuery.cs
- HostedTcpTransportManager.cs
- CodeGeneratorAttribute.cs
- ToolboxItem.cs
- Icon.cs
- TypeConverterAttribute.cs
- EventData.cs
- recordstatescratchpad.cs
- ObjectDataSourceWizardForm.cs
- ServerValidateEventArgs.cs
- FreezableDefaultValueFactory.cs
- Delegate.cs
- ClientCultureInfo.cs
- MenuItemStyleCollection.cs
- CommonDialog.cs
- XmlArrayAttribute.cs
- xmlglyphRunInfo.cs
- Parser.cs
- Application.cs
- RenderData.cs
- PersistChildrenAttribute.cs
- FileIOPermission.cs
- UriTemplate.cs
- CheckBox.cs
- TrackingRecord.cs
- Style.cs
- Mappings.cs
- MiniAssembly.cs
- IdentitySection.cs
- ViewCellSlot.cs
- GridViewSelectEventArgs.cs
- QilLoop.cs
- CustomLineCap.cs
- MetadataImporter.cs
- BuildManagerHost.cs
- ConfigurationSectionGroupCollection.cs
- HtmlInputSubmit.cs
- DescendantBaseQuery.cs
- Encoder.cs
- MergeFilterQuery.cs
- DynamicResourceExtensionConverter.cs
- XmlAttribute.cs
- CheckBoxBaseAdapter.cs
- CompositeControl.cs
- ApplicationServicesHostFactory.cs
- SqlConnectionFactory.cs
- RsaSecurityToken.cs
- XmlHelper.cs
- TreeViewImageIndexConverter.cs
- ErrorStyle.cs
- SamlConditions.cs
- CallbackWrapper.cs
- ClientSettingsProvider.cs
- PanelDesigner.cs
- TextSearch.cs
- DateTimeFormatInfoScanner.cs
- SimpleFileLog.cs
- KeyInterop.cs
- DropShadowEffect.cs
- SafeViewOfFileHandle.cs
- EntityStoreSchemaFilterEntry.cs
- WebServiceReceive.cs
- ApplicationServiceManager.cs
- MemoryFailPoint.cs
- RegexGroupCollection.cs
- Decimal.cs
- Internal.cs
- ReadOnlyHierarchicalDataSource.cs
- XmlSchemaSimpleTypeList.cs