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
- ParseChildrenAsPropertiesAttribute.cs
- ChtmlFormAdapter.cs
- WindowsTokenRoleProvider.cs
- AliasedSlot.cs
- FlowDocumentPageViewerAutomationPeer.cs
- WizardStepBase.cs
- CodeDOMProvider.cs
- InternalConfigHost.cs
- ObjectManager.cs
- VisualStyleInformation.cs
- DependencyProperty.cs
- ReflectionPermission.cs
- ResumeStoryboard.cs
- SmiXetterAccessMap.cs
- SecurityTimestamp.cs
- IncrementalCompileAnalyzer.cs
- XmlEnumAttribute.cs
- XmlILCommand.cs
- XmlStreamStore.cs
- CollectionsUtil.cs
- ResolvedKeyFrameEntry.cs
- Assert.cs
- PasswordRecovery.cs
- Privilege.cs
- ExceptionNotification.cs
- GuidelineCollection.cs
- DictionaryContent.cs
- CachedFontFamily.cs
- PersonalizationState.cs
- ColorTransformHelper.cs
- PolicyDesigner.cs
- Ports.cs
- ToolStripHighContrastRenderer.cs
- ResourceContainer.cs
- SiteMapSection.cs
- Oid.cs
- ConsoleEntryPoint.cs
- DetailsViewPageEventArgs.cs
- TimeSpanValidatorAttribute.cs
- MetadataArtifactLoader.cs
- PageContent.cs
- XPathNavigatorKeyComparer.cs
- HasActivatableWorkflowEvent.cs
- BufferModeSettings.cs
- BamlMapTable.cs
- Module.cs
- TransformerInfo.cs
- BindingGraph.cs
- CompositeTypefaceMetrics.cs
- XmlWrappingReader.cs
- ModelProperty.cs
- TextLineResult.cs
- StatusBarItemAutomationPeer.cs
- RequestSecurityTokenResponse.cs
- DuplicateWaitObjectException.cs
- DataGridViewSelectedCellCollection.cs
- ResourceType.cs
- SymmetricSecurityBindingElement.cs
- SupportingTokenListenerFactory.cs
- ListViewPagedDataSource.cs
- TextDocumentView.cs
- XmlNamespaceManager.cs
- SelectorItemAutomationPeer.cs
- ProxyAttribute.cs
- SmiMetaDataProperty.cs
- ComPlusAuthorization.cs
- WebServiceEnumData.cs
- XmlDocumentType.cs
- CodePageUtils.cs
- IInstanceTable.cs
- HttpWebResponse.cs
- StreamAsIStream.cs
- BamlTreeUpdater.cs
- DocumentXmlWriter.cs
- SQLDoubleStorage.cs
- CodeExporter.cs
- RoutedEventArgs.cs
- TextEditorTyping.cs
- Restrictions.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- WebConfigurationFileMap.cs
- DataSourceConverter.cs
- SystemWebSectionGroup.cs
- BrushConverter.cs
- ValueOfAction.cs
- TailPinnedEventArgs.cs
- PointLight.cs
- AlphaSortedEnumConverter.cs
- GridViewDeletedEventArgs.cs
- RelatedImageListAttribute.cs
- VarRefManager.cs
- PersistenceContext.cs
- AdapterUtil.cs
- RC2.cs
- PeerNode.cs
- FixUpCollection.cs
- PropertyValueUIItem.cs
- RegexWorker.cs
- TripleDESCryptoServiceProvider.cs
- TiffBitmapDecoder.cs