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
- IteratorDescriptor.cs
- NullReferenceException.cs
- ConstantProjectedSlot.cs
- Geometry.cs
- LowerCaseStringConverter.cs
- DocumentCollection.cs
- ToolboxCategoryItems.cs
- VarInfo.cs
- GetReadStreamResult.cs
- Adorner.cs
- DateTimeFormat.cs
- WebServiceReceive.cs
- DrawToolTipEventArgs.cs
- NameObjectCollectionBase.cs
- XPathNodeList.cs
- DrawingGroup.cs
- cookieexception.cs
- _HelperAsyncResults.cs
- RenderCapability.cs
- BackEase.cs
- WindowsIdentity.cs
- WebPartDisplayModeEventArgs.cs
- DataColumn.cs
- messageonlyhwndwrapper.cs
- DbLambda.cs
- CommandLineParser.cs
- CounterCreationData.cs
- OleDbPropertySetGuid.cs
- ThousandthOfEmRealPoints.cs
- SafeNativeMethods.cs
- AppDomainUnloadedException.cs
- NotifyParentPropertyAttribute.cs
- ImageBrush.cs
- Timer.cs
- RelationshipNavigation.cs
- Effect.cs
- WaitForChangedResult.cs
- LocalizableResourceBuilder.cs
- ClientFactory.cs
- StickyNote.cs
- WindowsTokenRoleProvider.cs
- XmlAttributeHolder.cs
- WebBrowserUriTypeConverter.cs
- TextLineBreak.cs
- PublisherIdentityPermission.cs
- CodeTryCatchFinallyStatement.cs
- EDesignUtil.cs
- JsonReader.cs
- DecimalSumAggregationOperator.cs
- FormattedTextSymbols.cs
- TimeSpanSecondsConverter.cs
- ListBoxItemAutomationPeer.cs
- XhtmlBasicObjectListAdapter.cs
- SafeHandles.cs
- FactoryGenerator.cs
- GacUtil.cs
- ConfigErrorGlyph.cs
- RevocationPoint.cs
- BigInt.cs
- AxHost.cs
- StorageTypeMapping.cs
- SymbolDocumentGenerator.cs
- TransformerInfoCollection.cs
- ProfessionalColorTable.cs
- CmsInterop.cs
- ProcessProtocolHandler.cs
- TTSEngineTypes.cs
- ChannelManagerService.cs
- StoryFragments.cs
- StatusStrip.cs
- MinMaxParagraphWidth.cs
- DeclaredTypeValidator.cs
- TableRowCollection.cs
- ProfileModule.cs
- XPathMessageFilterElement.cs
- IndependentAnimationStorage.cs
- RouteItem.cs
- MethodInfo.cs
- CmsInterop.cs
- WebServiceData.cs
- WebControl.cs
- BorderSidesEditor.cs
- XMLUtil.cs
- SSmlParser.cs
- DrawingCollection.cs
- ProxyGenerationError.cs
- PasswordRecoveryDesigner.cs
- StackOverflowException.cs
- NativeMsmqMessage.cs
- DateTimeValueSerializer.cs
- DateBoldEvent.cs
- SamlAssertionKeyIdentifierClause.cs
- _TimerThread.cs
- CatalogPartDesigner.cs
- ListViewDeleteEventArgs.cs
- ScriptHandlerFactory.cs
- OleDbTransaction.cs
- AudienceUriMode.cs
- SerializationInfoEnumerator.cs
- EventRecord.cs