Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / TraceEventCache.cs / 1305376 / TraceEventCache.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; using System.Security.Permissions; using System.Text; using System.Collections; using System.Globalization; using System.Runtime.Versioning; namespace System.Diagnostics { public class TraceEventCache { private static int processId; private static string processName; private long timeStamp = -1; private DateTime dateTime = DateTime.MinValue; private string stackTrace = null; internal Guid ActivityId { get { return Trace.CorrelationManager.ActivityId; } } public string Callstack { get { if (stackTrace == null) stackTrace = Environment.StackTrace; else new EnvironmentPermission(PermissionState.Unrestricted).Demand(); return stackTrace; } } public Stack LogicalOperationStack { get { return Trace.CorrelationManager.LogicalOperationStack; } } public DateTime DateTime { get { if (dateTime == DateTime.MinValue) dateTime = DateTime.UtcNow; return dateTime; } } public int ProcessId { [ResourceExposure(ResourceScope.Process)] // Returns the current process's pid [ResourceConsumption(ResourceScope.Process)] get { return GetProcessId(); } } public string ThreadId { get { return GetThreadId().ToString(CultureInfo.InvariantCulture); } } public long Timestamp { get { if (timeStamp == -1) timeStamp = Stopwatch.GetTimestamp(); return timeStamp ; } } [ResourceExposure(ResourceScope.None)] [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] private static void InitProcessInfo() { // Demand unmanaged code permission new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); if (processName == null) { Process p = Process.GetCurrentProcess(); try { processId = p.Id; processName = p.ProcessName; } finally { p.Dispose(); } } } [ResourceExposure(ResourceScope.Process)] internal static int GetProcessId() { InitProcessInfo(); return processId; } internal static string GetProcessName() { InitProcessInfo(); return processName; } internal static int GetThreadId() { return Thread.CurrentThread.ManagedThreadId; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SharedStatics.cs
- BitmapEffectGeneralTransform.cs
- DistinctQueryOperator.cs
- SelectedDatesCollection.cs
- AutoCompleteStringCollection.cs
- ThreadInterruptedException.cs
- RegistryDataKey.cs
- serverconfig.cs
- TdsParserSessionPool.cs
- __TransparentProxy.cs
- OpenTypeLayoutCache.cs
- DataGridViewRowCancelEventArgs.cs
- DynamicQueryStringParameter.cs
- DocumentViewerConstants.cs
- ColumnMapProcessor.cs
- _ConnectionGroup.cs
- PropertyConverter.cs
- AvtEvent.cs
- TextViewSelectionProcessor.cs
- CodeValidator.cs
- XmlSchemaComplexType.cs
- _Connection.cs
- XmlStreamStore.cs
- Variable.cs
- ReturnEventArgs.cs
- SHA1.cs
- TTSEngineTypes.cs
- ContractComponent.cs
- PathStreamGeometryContext.cs
- XpsResource.cs
- WebPartConnection.cs
- AlphabeticalEnumConverter.cs
- TransformerTypeCollection.cs
- Point3D.cs
- VectorValueSerializer.cs
- RenamedEventArgs.cs
- LocationEnvironment.cs
- DefaultEventAttribute.cs
- _NegoStream.cs
- WorkerRequest.cs
- UpdatePanelTrigger.cs
- ToolBarPanel.cs
- GPRECTF.cs
- ReadOnlyHierarchicalDataSourceView.cs
- StrokeDescriptor.cs
- ListBindingHelper.cs
- Formatter.cs
- GPRECTF.cs
- DefinitionBase.cs
- DiagnosticTrace.cs
- TextBoxRenderer.cs
- VisemeEventArgs.cs
- VerticalAlignConverter.cs
- XamlTemplateSerializer.cs
- Signature.cs
- TransformerConfigurationWizardBase.cs
- Lasso.cs
- FileRecordSequenceCompletedAsyncResult.cs
- SqlCharStream.cs
- DiscoveryClientProtocol.cs
- HttpProfileBase.cs
- WindowsListBox.cs
- DynamicPropertyReader.cs
- EntityDescriptor.cs
- PowerStatus.cs
- DeferredSelectedIndexReference.cs
- LayoutEngine.cs
- SqlUserDefinedAggregateAttribute.cs
- ServiceModelExtensionElement.cs
- XmlQueryRuntime.cs
- SqlDataAdapter.cs
- Timer.cs
- TrackingServices.cs
- FillRuleValidation.cs
- ConnectionPoolManager.cs
- DriveNotFoundException.cs
- DataListDesigner.cs
- Triplet.cs
- BookmarkScopeInfo.cs
- rsa.cs
- TextSyndicationContentKindHelper.cs
- Collection.cs
- HttpCacheParams.cs
- PageBuildProvider.cs
- AsymmetricSignatureFormatter.cs
- TdsParameterSetter.cs
- DefaultValueTypeConverter.cs
- RangeContentEnumerator.cs
- Rotation3D.cs
- SoapFormatterSinks.cs
- CommandID.cs
- IResourceProvider.cs
- StateRuntime.cs
- IndependentlyAnimatedPropertyMetadata.cs
- Point.cs
- OdbcParameterCollection.cs
- ToolStripComboBox.cs
- HiddenFieldDesigner.cs
- PartitionResolver.cs
- Models.cs