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
- Pipe.cs
- CodeNamespaceImportCollection.cs
- CalendarTable.cs
- LinkLabel.cs
- AccessText.cs
- CodeIterationStatement.cs
- XamlDesignerSerializationManager.cs
- dbdatarecord.cs
- OracleConnectionStringBuilder.cs
- DelegatingTypeDescriptionProvider.cs
- SimpleTextLine.cs
- TimersDescriptionAttribute.cs
- CharEnumerator.cs
- SiteMapSection.cs
- ChangeBlockUndoRecord.cs
- ExtractorMetadata.cs
- CompoundFileStreamReference.cs
- LinearKeyFrames.cs
- ToolStripSplitStackLayout.cs
- ColumnBinding.cs
- ExitEventArgs.cs
- StringToken.cs
- HtmlForm.cs
- TypeAccessException.cs
- StorageEntityContainerMapping.cs
- DialogWindow.cs
- ContextBase.cs
- FamilyTypefaceCollection.cs
- StorageInfo.cs
- LocationSectionRecord.cs
- ParsedRoute.cs
- FilteredSchemaElementLookUpTable.cs
- PriorityBinding.cs
- TypographyProperties.cs
- StreamReader.cs
- SchemaCollectionCompiler.cs
- RemotingAttributes.cs
- ObjectDataSource.cs
- EntityObject.cs
- DataGridToolTip.cs
- AdCreatedEventArgs.cs
- StringFormat.cs
- BitmapEffectDrawingContextState.cs
- SettingsPropertyNotFoundException.cs
- WindowsClaimSet.cs
- AddressUtility.cs
- FieldNameLookup.cs
- FormsIdentity.cs
- WebPartHeaderCloseVerb.cs
- DecimalFormatter.cs
- GatewayIPAddressInformationCollection.cs
- StaticExtension.cs
- ContentElementAutomationPeer.cs
- ItemCheckEvent.cs
- RouteItem.cs
- AttributeExtensions.cs
- Environment.cs
- DeploymentSectionCache.cs
- DiscoveryMessageSequence.cs
- ObjectTag.cs
- ApplicationServiceManager.cs
- SchemaHelper.cs
- NavigateEvent.cs
- FixUpCollection.cs
- BigInt.cs
- XmlSchemaType.cs
- GiveFeedbackEvent.cs
- DocumentOrderComparer.cs
- __TransparentProxy.cs
- CultureInfo.cs
- ArraySet.cs
- DataGridViewDataConnection.cs
- _DisconnectOverlappedAsyncResult.cs
- EdgeProfileValidation.cs
- WebPartTransformerAttribute.cs
- XPathNodeList.cs
- IncrementalReadDecoders.cs
- VarInfo.cs
- BinaryNegotiation.cs
- X509Chain.cs
- SystemDiagnosticsSection.cs
- SimpleWorkerRequest.cs
- StateManagedCollection.cs
- IPipelineRuntime.cs
- PackWebRequestFactory.cs
- Clock.cs
- RuntimeResourceSet.cs
- UTF7Encoding.cs
- TemplatePartAttribute.cs
- HttpClientCertificate.cs
- TraceProvider.cs
- BaseProcessor.cs
- DataGridViewRowsAddedEventArgs.cs
- XmlRawWriter.cs
- GroupBoxRenderer.cs
- LineInfo.cs
- Memoizer.cs
- WsdlExporter.cs
- ping.cs
- WindowManager.cs