Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / System / Diagnostics / TraceEventCache.cs / 1 / 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; 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 { get { return GetProcessId(); } } public string ThreadId { get { return GetThreadId().ToString(CultureInfo.InvariantCulture); } } public long Timestamp { get { if (timeStamp == -1) timeStamp = Stopwatch.GetTimestamp(); return timeStamp ; } } internal void Clear() { timeStamp = -1; dateTime = DateTime.MinValue; stackTrace = null; } 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(); } } } 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. //------------------------------------------------------------------------------ //// 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; 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 { get { return GetProcessId(); } } public string ThreadId { get { return GetThreadId().ToString(CultureInfo.InvariantCulture); } } public long Timestamp { get { if (timeStamp == -1) timeStamp = Stopwatch.GetTimestamp(); return timeStamp ; } } internal void Clear() { timeStamp = -1; dateTime = DateTime.MinValue; stackTrace = null; } 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(); } } } 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
- InputScopeAttribute.cs
- ToolStripArrowRenderEventArgs.cs
- NullableDecimalAverageAggregationOperator.cs
- CallbackValidator.cs
- Stackframe.cs
- ReadOnlyDictionary.cs
- SplashScreen.cs
- TargetInvocationException.cs
- MessageAction.cs
- __Filters.cs
- FormViewDesigner.cs
- DragDeltaEventArgs.cs
- TreeNodeCollectionEditorDialog.cs
- returneventsaver.cs
- InputScope.cs
- Keywords.cs
- SqlFactory.cs
- CodeRegionDirective.cs
- AnnotationComponentChooser.cs
- Wizard.cs
- SQLBinary.cs
- XamlTreeBuilderBamlRecordWriter.cs
- DataRowView.cs
- NativeMethods.cs
- cryptoapiTransform.cs
- FullTextBreakpoint.cs
- IndependentlyAnimatedPropertyMetadata.cs
- EventWaitHandleSecurity.cs
- ColorConvertedBitmap.cs
- NameValueCache.cs
- WorkflowPrinting.cs
- AsymmetricKeyExchangeFormatter.cs
- FrameworkRichTextComposition.cs
- OracleConnectionString.cs
- MDIClient.cs
- SqlReorderer.cs
- ToolboxComponentsCreatedEventArgs.cs
- UnsafeNativeMethods.cs
- AbsoluteQuery.cs
- CodePageEncoding.cs
- sitestring.cs
- ImageBrush.cs
- InvokeWebService.cs
- ThousandthOfEmRealDoubles.cs
- Span.cs
- BooleanSwitch.cs
- PrintPageEvent.cs
- ConnectionsZoneDesigner.cs
- AttributeData.cs
- CachedResourceDictionaryExtension.cs
- IndexedSelectQueryOperator.cs
- GlobalProxySelection.cs
- SupportingTokenDuplexChannel.cs
- RegistrySecurity.cs
- ZeroOpNode.cs
- IUnknownConstantAttribute.cs
- SafeCryptHandles.cs
- UIInitializationException.cs
- ScriptHandlerFactory.cs
- arabicshape.cs
- WindowsMenu.cs
- Exceptions.cs
- DataGridSortCommandEventArgs.cs
- DirectoryNotFoundException.cs
- NamedObject.cs
- TaiwanLunisolarCalendar.cs
- ADMembershipUser.cs
- TraceUtils.cs
- SharedConnectionWorkflowTransactionService.cs
- TabControlAutomationPeer.cs
- DesignerWithHeader.cs
- PointF.cs
- Geometry3D.cs
- ConditionCollection.cs
- Calendar.cs
- ToolstripProfessionalRenderer.cs
- PathGradientBrush.cs
- PersianCalendar.cs
- validation.cs
- XmlSubtreeReader.cs
- _LocalDataStoreMgr.cs
- ZoneIdentityPermission.cs
- BaseParagraph.cs
- TTSEngineProxy.cs
- HMACSHA384.cs
- StateChangeEvent.cs
- BrushConverter.cs
- GridToolTip.cs
- SrgsElementFactory.cs
- DetailsViewDeletedEventArgs.cs
- TPLETWProvider.cs
- CanExecuteRoutedEventArgs.cs
- unitconverter.cs
- SymbolType.cs
- DelegateSerializationHolder.cs
- TypeUsageBuilder.cs
- AudioFormatConverter.cs
- SmtpClient.cs
- AssociationType.cs
- SplashScreenNativeMethods.cs