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
- TreeIterator.cs
- WebBrowserNavigatedEventHandler.cs
- EncoderNLS.cs
- CompositeTypefaceMetrics.cs
- base64Transforms.cs
- SqlMultiplexer.cs
- CodeDirectionExpression.cs
- XmlRootAttribute.cs
- LinqDataSourceContextData.cs
- BaseServiceProvider.cs
- RectAnimationBase.cs
- SqlError.cs
- Tile.cs
- BitmapEffect.cs
- URLAttribute.cs
- FileDataSourceCache.cs
- InvalidOperationException.cs
- Collection.cs
- SqlBulkCopy.cs
- DockPatternIdentifiers.cs
- CFStream.cs
- HttpHandlerAction.cs
- CustomSignedXml.cs
- LockRecursionException.cs
- AstTree.cs
- ToRequest.cs
- securitymgrsite.cs
- InitializingNewItemEventArgs.cs
- WindowsAuthenticationEventArgs.cs
- Parallel.cs
- TraceHwndHost.cs
- EditorBrowsableAttribute.cs
- WebControlsSection.cs
- HtmlLabelAdapter.cs
- ReadingWritingEntityEventArgs.cs
- SelectorItemAutomationPeer.cs
- IOThreadScheduler.cs
- OracleBinary.cs
- TextElementEnumerator.cs
- LinearKeyFrames.cs
- EventSinkHelperWriter.cs
- WebPartUserCapability.cs
- DrawToolTipEventArgs.cs
- Rectangle.cs
- LayoutTableCell.cs
- BamlLocalizationDictionary.cs
- MarkerProperties.cs
- PopupRootAutomationPeer.cs
- QilDataSource.cs
- PagerSettings.cs
- ItemsControlAutomationPeer.cs
- TriggerCollection.cs
- CodeEntryPointMethod.cs
- ListViewPagedDataSource.cs
- ProfilePropertySettings.cs
- DataTableMappingCollection.cs
- SimpleWorkerRequest.cs
- XmlComplianceUtil.cs
- PropertyFilter.cs
- TypedTableBaseExtensions.cs
- PartialCachingAttribute.cs
- InternalConfigSettingsFactory.cs
- SimpleWebHandlerParser.cs
- Repeater.cs
- UpdatePanelControlTrigger.cs
- InfoCardProofToken.cs
- FormClosingEvent.cs
- X509CertificateCollection.cs
- FixedHyperLink.cs
- ActivityFunc.cs
- StringOutput.cs
- RelatedEnd.cs
- XmlSchemaProviderAttribute.cs
- AnnouncementEndpointElement.cs
- BrushMappingModeValidation.cs
- precedingsibling.cs
- EntityRecordInfo.cs
- IsolatedStoragePermission.cs
- RealizationContext.cs
- SafeWaitHandle.cs
- StringWriter.cs
- TrustSection.cs
- XmlDataSourceNodeDescriptor.cs
- XmlSchemaSimpleTypeUnion.cs
- CellTreeNodeVisitors.cs
- XmlSchemaElement.cs
- SafeCryptHandles.cs
- IndependentAnimationStorage.cs
- SQLChars.cs
- CustomWebEventKey.cs
- SiteMapDataSourceView.cs
- DataView.cs
- KnownTypes.cs
- QueryAccessibilityHelpEvent.cs
- IPipelineRuntime.cs
- Matrix3D.cs
- CultureMapper.cs
- TdsParameterSetter.cs
- XmlSchemaImporter.cs
- Regex.cs