Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- TextProviderWrapper.cs
- TokenCreationException.cs
- ServiceReference.cs
- SplineQuaternionKeyFrame.cs
- KeyedQueue.cs
- Point4D.cs
- CapabilitiesRule.cs
- WebServiceClientProxyGenerator.cs
- UiaCoreApi.cs
- XmlChoiceIdentifierAttribute.cs
- GPStream.cs
- DataViewSettingCollection.cs
- CatalogZoneBase.cs
- InterleavedZipPartStream.cs
- NullableDecimalMinMaxAggregationOperator.cs
- Baml2006ReaderSettings.cs
- VisualBasicSettingsHandler.cs
- MemberPath.cs
- RequestSecurityTokenSerializer.cs
- TokenBasedSetEnumerator.cs
- MailAddress.cs
- storepermissionattribute.cs
- AutoGeneratedField.cs
- Helpers.cs
- DataGridColumnCollectionEditor.cs
- BinaryParser.cs
- safelinkcollection.cs
- HttpClientCertificate.cs
- DataColumn.cs
- BatchParser.cs
- PaperSize.cs
- FromRequest.cs
- _SSPIWrapper.cs
- SQLByte.cs
- AvTrace.cs
- WebPartDescriptionCollection.cs
- ContextBase.cs
- HtmlInputImage.cs
- CodeVariableDeclarationStatement.cs
- InfoCardClaim.cs
- StateItem.cs
- Splitter.cs
- IQueryable.cs
- SqlInternalConnection.cs
- ProgressBarRenderer.cs
- RichTextBoxAutomationPeer.cs
- SID.cs
- _DomainName.cs
- DetailsViewDeletedEventArgs.cs
- ToolStripControlHost.cs
- ButtonChrome.cs
- IdnElement.cs
- Site.cs
- FixedSOMLineRanges.cs
- ScrollBarRenderer.cs
- FormsAuthenticationConfiguration.cs
- ProfileService.cs
- EventManager.cs
- _DisconnectOverlappedAsyncResult.cs
- EFColumnProvider.cs
- DataErrorValidationRule.cs
- PackageFilter.cs
- ControlAdapter.cs
- AssemblyFilter.cs
- XmlCharCheckingWriter.cs
- XmlMembersMapping.cs
- WebPartMinimizeVerb.cs
- CodeDomSerializer.cs
- SocketManager.cs
- ParameterReplacerVisitor.cs
- HtmlAnchor.cs
- PerfCounterSection.cs
- SimpleWorkerRequest.cs
- DataContractJsonSerializerOperationFormatter.cs
- CodeTypeReferenceCollection.cs
- QilGeneratorEnv.cs
- ToggleProviderWrapper.cs
- ObjectDataSourceEventArgs.cs
- PassportIdentity.cs
- BindMarkupExtensionSerializer.cs
- CellParagraph.cs
- ValidatorCompatibilityHelper.cs
- EmbeddedMailObject.cs
- GroupBox.cs
- ContravarianceAdapter.cs
- PathStreamGeometryContext.cs
- TraceHandlerErrorFormatter.cs
- MD5HashHelper.cs
- ExpressionBuilder.cs
- Int32Collection.cs
- ListParagraph.cs
- MembershipSection.cs
- NameGenerator.cs
- MetadataHelper.cs
- WindowsGrip.cs
- SpeechSeg.cs
- CompositeActivityDesigner.cs
- ColorEditor.cs
- XmlQueryType.cs
- Calendar.cs