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
- coordinatorfactory.cs
- TimeSpanValidatorAttribute.cs
- HttpListener.cs
- Types.cs
- DesigntimeLicenseContext.cs
- CfgParser.cs
- Double.cs
- RegexWorker.cs
- InvokePattern.cs
- SmtpDigestAuthenticationModule.cs
- EdmError.cs
- SendParametersContent.cs
- XmlAnyAttributeAttribute.cs
- Marshal.cs
- DbCommandDefinition.cs
- TagMapInfo.cs
- ListViewItem.cs
- LinkTarget.cs
- DesignerSelectionListAdapter.cs
- ObjectResult.cs
- WindowsTab.cs
- PropertyGeneratedEventArgs.cs
- UncommonField.cs
- SqlDuplicator.cs
- DocumentViewerConstants.cs
- AppearanceEditorPart.cs
- SystemWebCachingSectionGroup.cs
- RouteParametersHelper.cs
- Composition.cs
- WrapPanel.cs
- CommonDialog.cs
- DelegateTypeInfo.cs
- FragmentQueryKB.cs
- OleDbStruct.cs
- String.cs
- DaylightTime.cs
- MemberAssignmentAnalysis.cs
- ValidatorCollection.cs
- IImplicitResourceProvider.cs
- FontStyle.cs
- WebHttpSecurity.cs
- DirtyTextRange.cs
- pingexception.cs
- OutOfMemoryException.cs
- GenericXmlSecurityToken.cs
- PrimitiveCodeDomSerializer.cs
- ImageListUtils.cs
- UdpReplyToBehavior.cs
- UpdateProgress.cs
- RuntimeHelpers.cs
- Error.cs
- DocumentGridPage.cs
- webeventbuffer.cs
- ParseNumbers.cs
- EncryptedType.cs
- NotImplementedException.cs
- UIElement3D.cs
- CompilerError.cs
- TextPattern.cs
- ConfigurationSectionGroup.cs
- StreamUpgradeInitiator.cs
- Reference.cs
- TextChange.cs
- XmlBaseReader.cs
- WebPartMenuStyle.cs
- BaseAsyncResult.cs
- ObjectStateFormatter.cs
- ObjectStorage.cs
- TextCharacters.cs
- FilteredDataSetHelper.cs
- WizardForm.cs
- UniqueIdentifierService.cs
- ActivityExecutor.cs
- InternalConfigHost.cs
- RelationshipType.cs
- BinaryObjectReader.cs
- CheckBoxRenderer.cs
- HtmlInputHidden.cs
- ChannelServices.cs
- ConstraintStruct.cs
- ListViewInsertEventArgs.cs
- IndicCharClassifier.cs
- AddInActivator.cs
- OrderPreservingPipeliningSpoolingTask.cs
- FixedSOMTableRow.cs
- TableCell.cs
- FormsAuthenticationUserCollection.cs
- IRCollection.cs
- VariableBinder.cs
- LinkDescriptor.cs
- StringBlob.cs
- VBCodeProvider.cs
- FileCodeGroup.cs
- VisualStyleTypesAndProperties.cs
- OrderByQueryOptionExpression.cs
- ConvertTextFrag.cs
- BinaryObjectInfo.cs
- DesignerHierarchicalDataSourceView.cs
- DataGridViewComboBoxColumn.cs
- Label.cs