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
- GridSplitterAutomationPeer.cs
- ImageCollectionCodeDomSerializer.cs
- EmptyEnumerable.cs
- EditBehavior.cs
- MimeMultiPart.cs
- EngineSite.cs
- StrokeCollectionDefaultValueFactory.cs
- DataSetSchema.cs
- ToolStripItemImageRenderEventArgs.cs
- ConfigurationValue.cs
- InstanceLockLostException.cs
- Rotation3DAnimationBase.cs
- FastEncoder.cs
- DiffuseMaterial.cs
- TryCatchDesigner.xaml.cs
- EventData.cs
- ReaderContextStackData.cs
- ServerValidateEventArgs.cs
- processwaithandle.cs
- DeferredReference.cs
- PolyBezierSegmentFigureLogic.cs
- FrugalMap.cs
- ConfigurationManagerInternalFactory.cs
- PeerResolverMode.cs
- AvTraceFormat.cs
- KeysConverter.cs
- TrackingServices.cs
- MissingMethodException.cs
- IIS7UserPrincipal.cs
- SqlVersion.cs
- indexingfiltermarshaler.cs
- XmlSchemaImport.cs
- PrtCap_Reader.cs
- HtmlForm.cs
- AlgoModule.cs
- LinqDataSourceUpdateEventArgs.cs
- WebEventCodes.cs
- Popup.cs
- QilIterator.cs
- NamedPipeTransportBindingElement.cs
- TextTreeExtractElementUndoUnit.cs
- StylusButton.cs
- LambdaCompiler.ControlFlow.cs
- SqlOuterApplyReducer.cs
- ScriptManager.cs
- TextEditorParagraphs.cs
- FactoryGenerator.cs
- FrameworkName.cs
- DataGridViewColumnConverter.cs
- ProcessModuleDesigner.cs
- CredentialSelector.cs
- PartialClassGenerationTaskInternal.cs
- TreeViewDesigner.cs
- SiteMapPath.cs
- ResourcePool.cs
- ConsoleKeyInfo.cs
- Menu.cs
- MappingSource.cs
- _NegoState.cs
- HtmlSelect.cs
- XmlAttributeOverrides.cs
- WebControl.cs
- QueryContinueDragEvent.cs
- HtmlInputHidden.cs
- RowToParametersTransformer.cs
- ToolBarTray.cs
- FixedSOMFixedBlock.cs
- TextInfo.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- LinqToSqlWrapper.cs
- _BasicClient.cs
- TimerElapsedEvenArgs.cs
- EncodingTable.cs
- EmptyImpersonationContext.cs
- Material.cs
- RepeatButtonAutomationPeer.cs
- Authorization.cs
- FormatPage.cs
- EnumerableRowCollectionExtensions.cs
- DateTimeOffset.cs
- HttpCookiesSection.cs
- PKCS1MaskGenerationMethod.cs
- AttachedAnnotationChangedEventArgs.cs
- DotNetATv1WindowsLogEntrySerializer.cs
- UnionCqlBlock.cs
- HttpModuleActionCollection.cs
- TabPage.cs
- BitmapEffectrendercontext.cs
- RegistrationServices.cs
- ObjectListComponentEditor.cs
- ProgressChangedEventArgs.cs
- BooleanFunctions.cs
- OdbcConnectionOpen.cs
- UrlAuthorizationModule.cs
- UnsafeNativeMethods.cs
- StringUtil.cs
- TimeSpan.cs
- ClientRoleProvider.cs
- HitTestFilterBehavior.cs
- PagesChangedEventArgs.cs