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
- ViewRendering.cs
- VolatileEnlistmentMultiplexing.cs
- _AcceptOverlappedAsyncResult.cs
- ExtensionFile.cs
- ActionMessageFilter.cs
- MultiSelectRootGridEntry.cs
- OwnerDrawPropertyBag.cs
- Vector3DAnimationUsingKeyFrames.cs
- HttpModuleActionCollection.cs
- WebPartConnection.cs
- RegexCompilationInfo.cs
- ScriptServiceAttribute.cs
- BindingList.cs
- DbgUtil.cs
- OAVariantLib.cs
- InputScopeNameConverter.cs
- EventLogQuery.cs
- MemberMaps.cs
- CommandHelpers.cs
- PreProcessor.cs
- HttpGetProtocolImporter.cs
- Filter.cs
- UrlParameterReader.cs
- CompatibleComparer.cs
- ObjectItemCollection.cs
- DecoderReplacementFallback.cs
- ColumnHeader.cs
- PageSetupDialog.cs
- TextPattern.cs
- CommandValueSerializer.cs
- ClientScriptManager.cs
- GridView.cs
- XmlNamedNodeMap.cs
- SmtpMail.cs
- SeverityFilter.cs
- ConfigurationSection.cs
- CloseCollectionAsyncResult.cs
- WindowShowOrOpenTracker.cs
- TdsRecordBufferSetter.cs
- ActivityExecutionContext.cs
- COM2ExtendedBrowsingHandler.cs
- XamlSerializerUtil.cs
- BookmarkTable.cs
- DelegateTypeInfo.cs
- BamlResourceContent.cs
- Quaternion.cs
- ClientFormsAuthenticationCredentials.cs
- SmtpNetworkElement.cs
- QilUnary.cs
- PrefixHandle.cs
- OperatingSystemVersionCheck.cs
- ColorContext.cs
- ConstraintManager.cs
- OleDbRowUpdatedEvent.cs
- GeneratedCodeAttribute.cs
- FunctionDetailsReader.cs
- GridViewUpdateEventArgs.cs
- WSDualHttpSecurity.cs
- HttpHandler.cs
- GridViewPageEventArgs.cs
- StoryFragments.cs
- altserialization.cs
- NestedContainer.cs
- TextParaLineResult.cs
- EntitySetBaseCollection.cs
- EdmEntityTypeAttribute.cs
- NullableConverter.cs
- QilInvokeLateBound.cs
- TableDetailsCollection.cs
- NonPrimarySelectionGlyph.cs
- TreeNodeCollection.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- MailAddress.cs
- CodeLabeledStatement.cs
- IndentedTextWriter.cs
- ResolveMatchesMessageCD1.cs
- MultiTrigger.cs
- ActivationWorker.cs
- PagePropertiesChangingEventArgs.cs
- Attributes.cs
- SystemParameters.cs
- SendingRequestEventArgs.cs
- SoapTransportImporter.cs
- TableStyle.cs
- TerminatingOperationBehavior.cs
- WebPartCancelEventArgs.cs
- BreakSafeBase.cs
- RouteItem.cs
- BinaryNode.cs
- NetworkCredential.cs
- SchemaTypeEmitter.cs
- QilCloneVisitor.cs
- Listbox.cs
- XmlSchemaSimpleTypeUnion.cs
- SoapElementAttribute.cs
- AddInServer.cs
- TokenizerHelper.cs
- ErrorProvider.cs
- ListViewInsertionMark.cs
- UrlPropertyAttribute.cs