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
- FileClassifier.cs
- InfoCardCryptoHelper.cs
- DataGridViewSelectedColumnCollection.cs
- InputLanguageEventArgs.cs
- SamlDelegatingWriter.cs
- BitStream.cs
- StringAnimationUsingKeyFrames.cs
- DBSqlParserTableCollection.cs
- ProfessionalColors.cs
- X509AsymmetricSecurityKey.cs
- DataGridSortingEventArgs.cs
- XmlParser.cs
- TextClipboardData.cs
- PermissionToken.cs
- SessionStateItemCollection.cs
- PerformanceCounterCategory.cs
- ProcessInfo.cs
- DocumentApplicationDocumentViewer.cs
- DataGridViewSortCompareEventArgs.cs
- DesignerWebPartChrome.cs
- SplashScreen.cs
- DataGridGeneralPage.cs
- KnownBoxes.cs
- CommonObjectSecurity.cs
- XmlException.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- ClientSession.cs
- ToolboxItemFilterAttribute.cs
- SelectionItemProviderWrapper.cs
- LZCodec.cs
- SmiEventSink_Default.cs
- QilXmlWriter.cs
- SqlRowUpdatingEvent.cs
- SpellCheck.cs
- StyleHelper.cs
- HttpServerVarsCollection.cs
- LockedAssemblyCache.cs
- SessionEndingEventArgs.cs
- ScrollChrome.cs
- UpdateManifestForBrowserApplication.cs
- XsltOutput.cs
- UInt64.cs
- CoordinationService.cs
- IxmlLineInfo.cs
- PnrpPermission.cs
- ResetableIterator.cs
- ColorConverter.cs
- InputMethodStateTypeInfo.cs
- RootProfilePropertySettingsCollection.cs
- QilXmlReader.cs
- DataPagerCommandEventArgs.cs
- Debug.cs
- DriveInfo.cs
- GridViewDeleteEventArgs.cs
- MemberAccessException.cs
- StreamResourceInfo.cs
- SemanticAnalyzer.cs
- VisualStyleTypesAndProperties.cs
- LOSFormatter.cs
- SizeConverter.cs
- EditorServiceContext.cs
- GPRECTF.cs
- ToolStripDropDownButton.cs
- ResourceExpressionEditorSheet.cs
- DataBoundLiteralControl.cs
- SerializationFieldInfo.cs
- NegationPusher.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- WebPartVerbCollection.cs
- WindowsListViewGroupHelper.cs
- XPathMessageFilterElementComparer.cs
- ProgressBarBrushConverter.cs
- DataControlPagerLinkButton.cs
- OdbcConnectionFactory.cs
- ErasingStroke.cs
- EntityViewGenerator.cs
- WebPartTransformerAttribute.cs
- ValidationRuleCollection.cs
- TabControlEvent.cs
- FeatureSupport.cs
- WindowsFormsDesignerOptionService.cs
- BreakRecordTable.cs
- EventLogReader.cs
- WindowsPen.cs
- DictionaryCustomTypeDescriptor.cs
- ColorBlend.cs
- PublisherIdentityPermission.cs
- IconHelper.cs
- BuildProvidersCompiler.cs
- Aggregates.cs
- ProtocolsConfigurationHandler.cs
- ExpanderAutomationPeer.cs
- SQLMembershipProvider.cs
- DataGridColumnCollectionEditor.cs
- WpfKnownMember.cs
- documentsequencetextcontainer.cs
- WebEventCodes.cs
- GraphicsContext.cs
- ImageBrush.cs
- EdmItemError.cs