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
- BindingMAnagerBase.cs
- CommonDialog.cs
- DynamicArgumentDialog.cs
- InertiaTranslationBehavior.cs
- PropertyTab.cs
- NativeMethods.cs
- X509UI.cs
- _AutoWebProxyScriptEngine.cs
- LeftCellWrapper.cs
- InkCollectionBehavior.cs
- HttpHandlersSection.cs
- MessageBodyDescription.cs
- XmlEnumAttribute.cs
- Activator.cs
- EventListener.cs
- assertwrapper.cs
- FormViewDeleteEventArgs.cs
- DetailsViewPageEventArgs.cs
- XsltSettings.cs
- SspiWrapper.cs
- SiteMapDataSource.cs
- AssemblyInfo.cs
- TextServicesHost.cs
- BulletChrome.cs
- COM2ExtendedTypeConverter.cs
- EntityDataSourceChangedEventArgs.cs
- Scene3D.cs
- Slider.cs
- WorkflowDesignerMessageFilter.cs
- GenericRootAutomationPeer.cs
- EntityConnection.cs
- ExpressionBuilder.cs
- ToolStripRenderer.cs
- Oid.cs
- Soap12ProtocolImporter.cs
- CapabilitiesUse.cs
- Vector3DConverter.cs
- LeafCellTreeNode.cs
- IssuedSecurityTokenParameters.cs
- SoapInteropTypes.cs
- ExpandSegment.cs
- ProviderCommandInfoUtils.cs
- DataViewSetting.cs
- CursorInteropHelper.cs
- BindingUtils.cs
- ProvideValueServiceProvider.cs
- InstanceDataCollection.cs
- BlobPersonalizationState.cs
- DockPatternIdentifiers.cs
- GridViewUpdatedEventArgs.cs
- NavigatorOutput.cs
- FormsAuthentication.cs
- EntityDataSourceViewSchema.cs
- RadioButtonPopupAdapter.cs
- XmlWrappingReader.cs
- StreamResourceInfo.cs
- ClientSideQueueItem.cs
- CompModSwitches.cs
- BamlVersionHeader.cs
- returneventsaver.cs
- Activity.cs
- ExtentJoinTreeNode.cs
- LocatorGroup.cs
- XmlNamespaceDeclarationsAttribute.cs
- InvariantComparer.cs
- SqlAliasesReferenced.cs
- SqlMethodAttribute.cs
- DataRecordInternal.cs
- RefType.cs
- DeflateEmulationStream.cs
- SqlStatistics.cs
- ExtendedProtectionPolicyElement.cs
- XmlSchemaValidator.cs
- LogLogRecord.cs
- RowUpdatedEventArgs.cs
- BreakRecordTable.cs
- XmlCharCheckingWriter.cs
- MailDefinition.cs
- User.cs
- WindowsFormsSectionHandler.cs
- HttpListenerContext.cs
- _FtpControlStream.cs
- SchemaImporterExtensionsSection.cs
- Enum.cs
- KoreanCalendar.cs
- _LocalDataStore.cs
- DockProviderWrapper.cs
- RpcResponse.cs
- SerialPinChanges.cs
- ResizeGrip.cs
- LocalizableAttribute.cs
- JournalEntry.cs
- UnescapedXmlDiagnosticData.cs
- X509Certificate2Collection.cs
- RestHandler.cs
- RequestSecurityTokenForGetBrowserToken.cs
- _SafeNetHandles.cs
- UnsafeNativeMethods.cs
- HtmlInputRadioButton.cs
- MenuItemStyleCollection.cs