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
- Profiler.cs
- ClaimTypes.cs
- TypedReference.cs
- DataTable.cs
- GetLastErrorDetailsRequest.cs
- GridViewDeleteEventArgs.cs
- DirtyTextRange.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- ConfigurationException.cs
- UnsafeNativeMethods.cs
- SafeRightsManagementQueryHandle.cs
- DateTimeConverter.cs
- EditorPart.cs
- WriteTimeStream.cs
- ProviderCommandInfoUtils.cs
- TextTreeTextElementNode.cs
- DynamicRendererThreadManager.cs
- DefaultShape.cs
- DateTimeParse.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SqlConnection.cs
- CryptoProvider.cs
- DefaultPropertyAttribute.cs
- TraceFilter.cs
- AssertUtility.cs
- PageParser.cs
- ProxyGenerationError.cs
- KnowledgeBase.cs
- TablePattern.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- ModifyActivitiesPropertyDescriptor.cs
- COM2PropertyDescriptor.cs
- RecordBuilder.cs
- WindowsIPAddress.cs
- DeadCharTextComposition.cs
- RuntimeWrappedException.cs
- DataGridViewSelectedRowCollection.cs
- FormsAuthenticationConfiguration.cs
- ToolStripCustomTypeDescriptor.cs
- FontDriver.cs
- SuppressMessageAttribute.cs
- HttpCookieCollection.cs
- ResolveDuplexAsyncResult.cs
- DBConnectionString.cs
- NotifyParentPropertyAttribute.cs
- GatewayIPAddressInformationCollection.cs
- BitmapEffectInput.cs
- MsmqInputChannelBase.cs
- CustomLineCap.cs
- RemoteWebConfigurationHost.cs
- GenericAuthenticationEventArgs.cs
- SchemaCollectionCompiler.cs
- DataBoundLiteralControl.cs
- ObjectListDesigner.cs
- EntityCommand.cs
- httpserverutility.cs
- EventListenerClientSide.cs
- BoundField.cs
- Hashtable.cs
- DynamicHyperLink.cs
- Stream.cs
- SqlReorderer.cs
- HostingEnvironment.cs
- Crc32.cs
- Floater.cs
- QuaternionRotation3D.cs
- MachinePropertyVariants.cs
- ContainerFilterService.cs
- ItemCheckEvent.cs
- RtfNavigator.cs
- Matrix.cs
- CodeMethodReturnStatement.cs
- ValidationHelper.cs
- PersonalizationProvider.cs
- TTSVoice.cs
- Int32RectValueSerializer.cs
- wgx_commands.cs
- SerializerDescriptor.cs
- MiniConstructorInfo.cs
- SortQuery.cs
- CallbackWrapper.cs
- StaticContext.cs
- TransactionFilter.cs
- AssemblyUtil.cs
- AuthorizationSection.cs
- _ProxyRegBlob.cs
- RouteItem.cs
- CryptoKeySecurity.cs
- SignedPkcs7.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ELinqQueryState.cs
- AstTree.cs
- ReturnValue.cs
- CheckedPointers.cs
- cookiecontainer.cs
- EventDescriptorCollection.cs
- ReadWriteSpinLock.cs
- AsymmetricSignatureFormatter.cs
- StringInfo.cs
- DiagnosticEventProvider.cs