Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / 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. 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
- MobileControlBuilder.cs
- ToolBarPanel.cs
- ValueSerializerAttribute.cs
- ParagraphVisual.cs
- ZipIOLocalFileBlock.cs
- TrackingProfileDeserializationException.cs
- Timer.cs
- HtmlToClrEventProxy.cs
- InputMethodStateTypeInfo.cs
- TypedRowHandler.cs
- DataGridState.cs
- FileStream.cs
- NetworkInterface.cs
- WebBrowsableAttribute.cs
- RIPEMD160.cs
- OdbcEnvironmentHandle.cs
- BmpBitmapEncoder.cs
- LinkTarget.cs
- TextTreeObjectNode.cs
- HttpModulesInstallComponent.cs
- DataGridViewSelectedCellCollection.cs
- SequenceFullException.cs
- UrlPath.cs
- SchemaAttDef.cs
- WindowsTab.cs
- ExtensionQuery.cs
- XmlSerializableReader.cs
- WebBrowserHelper.cs
- PageSetupDialog.cs
- UnsafeNativeMethods.cs
- DetailsViewInsertedEventArgs.cs
- RoutingConfiguration.cs
- LayeredChannelFactory.cs
- MultiDataTrigger.cs
- EnumCodeDomSerializer.cs
- RuntimeResourceSet.cs
- UInt16Storage.cs
- LongValidator.cs
- XPathNodeHelper.cs
- OperandQuery.cs
- ConfigXmlReader.cs
- LogicalTreeHelper.cs
- SchemaImporter.cs
- XmlChildEnumerator.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- _Events.cs
- AssertFilter.cs
- ColorBlend.cs
- WebPartRestoreVerb.cs
- KeyMatchBuilder.cs
- BinaryFormatterWriter.cs
- HandlerBase.cs
- SessionStateModule.cs
- HitTestResult.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- C14NUtil.cs
- SpellCheck.cs
- ScrollBarAutomationPeer.cs
- ReferenceService.cs
- AnnotationComponentManager.cs
- TypeElementCollection.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- ValueUtilsSmi.cs
- SerializationFieldInfo.cs
- _BasicClient.cs
- DBBindings.cs
- FixedNode.cs
- TextSpanModifier.cs
- StringInfo.cs
- documentsequencetextpointer.cs
- EncryptedType.cs
- ReflectionUtil.cs
- DesignObjectWrapper.cs
- SuppressMergeCheckAttribute.cs
- MemoryMappedViewStream.cs
- DefaultParameterValueAttribute.cs
- XmlEventCache.cs
- IntPtr.cs
- WebPartVerbsEventArgs.cs
- PermissionSet.cs
- DesignerToolStripControlHost.cs
- WebBrowser.cs
- PropertyDescriptorComparer.cs
- ProcessThread.cs
- IxmlLineInfo.cs
- mediaeventargs.cs
- Point3DAnimationBase.cs
- TextCompositionManager.cs
- SmtpFailedRecipientsException.cs
- OracleConnectionStringBuilder.cs
- Environment.cs
- WorkflowViewStateService.cs
- ApplySecurityAndSendAsyncResult.cs
- ToolStripMenuItem.cs
- MDIControlStrip.cs
- HttpWebRequestElement.cs
- ListParagraph.cs
- Serializer.cs
- ScriptManagerProxy.cs
- __Filters.cs