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
- HttpModuleAction.cs
- XmlAttributeAttribute.cs
- DataGridViewCellCancelEventArgs.cs
- SqlDataReaderSmi.cs
- UserControlAutomationPeer.cs
- NotImplementedException.cs
- DbConnectionStringCommon.cs
- GlobalizationAssembly.cs
- XmlTypeAttribute.cs
- DataSourceSelectArguments.cs
- MethodSignatureGenerator.cs
- WorkflowMarkupSerializer.cs
- HttpWriter.cs
- CodeArrayIndexerExpression.cs
- OleDbWrapper.cs
- IntegerValidator.cs
- Line.cs
- UInt32.cs
- ScrollBar.cs
- DataTable.cs
- IndexOutOfRangeException.cs
- AccessText.cs
- CompilerError.cs
- ProviderException.cs
- DataControlCommands.cs
- PowerStatus.cs
- DefaultProxySection.cs
- RichTextBoxContextMenu.cs
- Model3D.cs
- DefaultPropertyAttribute.cs
- XmlCharType.cs
- DataGridViewEditingControlShowingEventArgs.cs
- FilteredAttributeCollection.cs
- SqlConnectionStringBuilder.cs
- WSFederationHttpSecurity.cs
- ConfigurationValidatorBase.cs
- CompiledXpathExpr.cs
- RemoteWebConfigurationHost.cs
- XPathException.cs
- MappingModelBuildProvider.cs
- TextRangeSerialization.cs
- DataMemberAttribute.cs
- AndMessageFilterTable.cs
- PropertyInfoSet.cs
- CodeNamespaceCollection.cs
- bindurihelper.cs
- Timer.cs
- Inline.cs
- OutOfProcStateClientManager.cs
- RulePatternOps.cs
- ModelPropertyDescriptor.cs
- ScrollBarRenderer.cs
- TypeDescriptionProviderAttribute.cs
- TemplateLookupAction.cs
- _SslStream.cs
- SoapAttributes.cs
- QuadraticBezierSegment.cs
- Serializer.cs
- FileSystemEventArgs.cs
- StorageAssociationTypeMapping.cs
- SafeBitVector32.cs
- BitmapEncoder.cs
- DesignOnlyAttribute.cs
- RelatedPropertyManager.cs
- SecurityCookieModeValidator.cs
- SetIterators.cs
- GetPageNumberCompletedEventArgs.cs
- ChangeTracker.cs
- DataGridRowDetailsEventArgs.cs
- CacheHelper.cs
- sqlpipe.cs
- FocusTracker.cs
- TransportationConfigurationTypeInstallComponent.cs
- SID.cs
- XmlSchemaNotation.cs
- Listen.cs
- DispatcherExceptionEventArgs.cs
- ToolStripGripRenderEventArgs.cs
- IndexObject.cs
- GcSettings.cs
- HttpWebRequest.cs
- RelatedCurrencyManager.cs
- TextSelectionHighlightLayer.cs
- ProtocolElement.cs
- TypeToStringValueConverter.cs
- CodeConstructor.cs
- SspiSafeHandles.cs
- IndexedEnumerable.cs
- InvariantComparer.cs
- smtpconnection.cs
- HostedImpersonationContext.cs
- MouseActionConverter.cs
- ServiceCredentials.cs
- XmlDocumentFragment.cs
- ForceCopyBuildProvider.cs
- TraceSwitch.cs
- ImageIndexConverter.cs
- ActiveXMessageFormatter.cs
- PrintingPermissionAttribute.cs
- DataDocumentXPathNavigator.cs