Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / ProcessMonitor.cs / 1 / ProcessMonitor.cs
namespace Microsoft.InfoCards { using System; using System.ComponentModel; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; internal class ProcessMonitor { static ProcessMonitor s_current = new ProcessMonitor(); Dictionarym_cache; object m_sync; private ProcessMonitor() { m_sync = new object(); m_cache = new Dictionary (); } public static Process GetProcessById( int id ) { return s_current.InnerGetProcessById( id ); } Process InnerGetProcessById( int id ) { Process process = null; lock( m_sync ) { if( !m_cache.TryGetValue( id, out process ) ) { process = Process.GetProcessById( id ); if( !process.HasExited ) { InitializeProcessObject( process ); // // add the entry to the cache. // m_cache.Add( process.Id, process ); } } } return process; } void InitializeProcessObject( Process process ) { // // This call can create a thread when setting the value to true. // process.EnableRaisingEvents = true; process.Exited += new EventHandler( Process_Exited ); } void Process_Exited( object sender, EventArgs e ) { Process process = (Process)sender; lock( m_sync ) { m_cache.Remove( process.Id ); } process.Exited -= new EventHandler( Process_Exited ); } } } // 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
- WebPartUtil.cs
- UniqueIdentifierService.cs
- RoutedCommand.cs
- DeferredTextReference.cs
- SerializationFieldInfo.cs
- TextChange.cs
- ToolStripItemDataObject.cs
- CodeStatementCollection.cs
- EntityClientCacheKey.cs
- UnsafeNativeMethods.cs
- base64Transforms.cs
- ScriptReferenceEventArgs.cs
- EncryptedHeaderXml.cs
- CodeExporter.cs
- ProjectionPruner.cs
- ButtonAutomationPeer.cs
- SerialPinChanges.cs
- DefaultValueConverter.cs
- WebPartConnectionsDisconnectVerb.cs
- XmlEventCache.cs
- SimpleRecyclingCache.cs
- odbcmetadatacollectionnames.cs
- BaseValidator.cs
- IndexedString.cs
- securitycriticaldataClass.cs
- RawUIStateInputReport.cs
- ObjectDataSourceEventArgs.cs
- GradientStopCollection.cs
- ResourcePermissionBase.cs
- DockAndAnchorLayout.cs
- Int32EqualityComparer.cs
- Button.cs
- QueueProcessor.cs
- PageVisual.cs
- DataExpression.cs
- VisualState.cs
- entitydatasourceentitysetnameconverter.cs
- TwoPhaseCommit.cs
- ControlUtil.cs
- VerticalAlignConverter.cs
- ReflectionHelper.cs
- LZCodec.cs
- InvalidEnumArgumentException.cs
- ExtendedPropertyDescriptor.cs
- XmlName.cs
- serverconfig.cs
- HtmlTableCellCollection.cs
- BitConverter.cs
- AddingNewEventArgs.cs
- ComponentDispatcherThread.cs
- XmlQueryStaticData.cs
- TreeIterator.cs
- MatrixCamera.cs
- EdmItemError.cs
- XmlSchemaResource.cs
- LocalizationComments.cs
- FrameworkElement.cs
- DesignerVerbToolStripMenuItem.cs
- WindowsComboBox.cs
- SmtpNetworkElement.cs
- SpeechSynthesizer.cs
- HostingEnvironment.cs
- SimpleLine.cs
- CodeDomSerializerBase.cs
- MenuAutoFormat.cs
- EntityProviderFactory.cs
- IndexedSelectQueryOperator.cs
- ScaleTransform.cs
- PropertyEntry.cs
- DbCommandDefinition.cs
- ChangePasswordDesigner.cs
- OleDbStruct.cs
- StringArrayConverter.cs
- DiscoveryDocumentSearchPattern.cs
- SqlBulkCopyColumnMappingCollection.cs
- TextBox.cs
- Symbol.cs
- MemberHolder.cs
- ConnectivityStatus.cs
- FileSystemEventArgs.cs
- UIPermission.cs
- XXXInfos.cs
- HttpWrapper.cs
- TextEffect.cs
- TempEnvironment.cs
- WebDisplayNameAttribute.cs
- DataRowChangeEvent.cs
- GridViewSelectEventArgs.cs
- RewritingValidator.cs
- ListManagerBindingsCollection.cs
- BrowsableAttribute.cs
- AssociationTypeEmitter.cs
- LineSegment.cs
- _LocalDataStore.cs
- HwndStylusInputProvider.cs
- AtomParser.cs
- EntityDataSource.cs
- _SslState.cs
- SingleAnimationBase.cs
- ConfigurationManager.cs