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
- Point4DValueSerializer.cs
- JoinElimination.cs
- BreakSafeBase.cs
- MenuItemAutomationPeer.cs
- SamlSerializer.cs
- BlockCollection.cs
- XmlFormatExtensionPointAttribute.cs
- QilInvokeEarlyBound.cs
- InteropBitmapSource.cs
- ScopelessEnumAttribute.cs
- CheckBoxBaseAdapter.cs
- WebPartEditorApplyVerb.cs
- FontStyle.cs
- PointConverter.cs
- SqlSelectStatement.cs
- HtmlTernaryTree.cs
- RequestQueue.cs
- DefaultParameterValueAttribute.cs
- XmlSchemaNotation.cs
- DetailsViewRow.cs
- MiniLockedBorderGlyph.cs
- LayoutSettings.cs
- MetroSerializationManager.cs
- ColumnWidthChangingEvent.cs
- TouchesOverProperty.cs
- ItemChangedEventArgs.cs
- ApplicationFileCodeDomTreeGenerator.cs
- IISMapPath.cs
- InheritablePropertyChangeInfo.cs
- Matrix3D.cs
- NotSupportedException.cs
- SrgsGrammar.cs
- IdnElement.cs
- XamlSerializer.cs
- UnaryNode.cs
- WebPartManagerInternals.cs
- DecimalAnimation.cs
- TempFiles.cs
- FilterQuery.cs
- HttpListenerRequestTraceRecord.cs
- RelationshipEndCollection.cs
- GenericPrincipal.cs
- DataQuery.cs
- DnsCache.cs
- NumericExpr.cs
- Point3DCollection.cs
- WebControlsSection.cs
- Mapping.cs
- ObjectDataSourceSelectingEventArgs.cs
- ParserOptions.cs
- ObjectViewFactory.cs
- HtmlElementCollection.cs
- DeadCharTextComposition.cs
- _HelperAsyncResults.cs
- Camera.cs
- IChannel.cs
- MsmqBindingElementBase.cs
- WebPartVerb.cs
- WsrmFault.cs
- HelpExampleGenerator.cs
- WmlTextBoxAdapter.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- SafeHandles.cs
- IconHelper.cs
- PassportAuthentication.cs
- ErrorLog.cs
- ScrollProviderWrapper.cs
- WebPartHelpVerb.cs
- HandledMouseEvent.cs
- HwndKeyboardInputProvider.cs
- CompilerErrorCollection.cs
- MethodImplAttribute.cs
- TransformerInfo.cs
- HttpListenerContext.cs
- Stack.cs
- DataGridHelper.cs
- Content.cs
- TextFormatterHost.cs
- SessionPageStateSection.cs
- SoapAttributeOverrides.cs
- BinaryObjectWriter.cs
- TemplateBindingExpressionConverter.cs
- XmlDownloadManager.cs
- RadioButtonRenderer.cs
- RawStylusInputCustomData.cs
- xml.cs
- ToolBar.cs
- QilInvoke.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- PartialTrustVisibleAssembliesSection.cs
- DelayedRegex.cs
- ListSortDescription.cs
- CultureData.cs
- SqlClientWrapperSmiStream.cs
- CorePropertiesFilter.cs
- GeneralTransformCollection.cs
- ExpandSegment.cs
- SubMenuStyle.cs
- ClipboardData.cs
- SingleResultAttribute.cs