Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- reliableinputsessionchannel.cs
- EnumBuilder.cs
- HttpCapabilitiesEvaluator.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- WeakReferenceKey.cs
- MatchNoneMessageFilter.cs
- HttpResponse.cs
- autovalidator.cs
- AttachedPropertyMethodSelector.cs
- DataGridViewCellFormattingEventArgs.cs
- HitTestParameters3D.cs
- FocusManager.cs
- Function.cs
- Viewport3DVisual.cs
- ModelUIElement3D.cs
- RegexCapture.cs
- GridEntryCollection.cs
- ArgumentReference.cs
- ColorAnimationUsingKeyFrames.cs
- ComboBoxItem.cs
- PropertyTabAttribute.cs
- CodeObject.cs
- SqlTriggerContext.cs
- CheckBoxRenderer.cs
- NotCondition.cs
- CodeExpressionStatement.cs
- SqlDataSourceRefreshSchemaForm.cs
- HGlobalSafeHandle.cs
- XamlReaderHelper.cs
- PolyLineSegmentFigureLogic.cs
- ArgumentDirectionHelper.cs
- AppLevelCompilationSectionCache.cs
- SQLByteStorage.cs
- PeerEndPoint.cs
- counter.cs
- ScrollViewer.cs
- CodeLabeledStatement.cs
- LineSegment.cs
- StylusPointPropertyUnit.cs
- TableRowGroup.cs
- ServicePointManager.cs
- HostedHttpTransportManager.cs
- ProxyManager.cs
- SqlProfileProvider.cs
- UnhandledExceptionEventArgs.cs
- ConcurrentStack.cs
- DataGridViewRowStateChangedEventArgs.cs
- CommandField.cs
- RegistrySecurity.cs
- PassportAuthenticationModule.cs
- XhtmlTextWriter.cs
- SchemaImporterExtensionElementCollection.cs
- Clipboard.cs
- RadioButtonList.cs
- sqlcontext.cs
- XmlSchemaSequence.cs
- TableFieldsEditor.cs
- ScrollData.cs
- RequestCachePolicy.cs
- CodeVariableDeclarationStatement.cs
- PinnedBufferMemoryStream.cs
- typedescriptorpermissionattribute.cs
- XmlTextReaderImplHelpers.cs
- IImplicitResourceProvider.cs
- ProcessModule.cs
- DetailsView.cs
- KnownColorTable.cs
- HtmlInputButton.cs
- MultipleFilterMatchesException.cs
- ByteAnimationUsingKeyFrames.cs
- XmlObjectSerializerWriteContext.cs
- ConfigurationElement.cs
- TextPointerBase.cs
- TextBox.cs
- TraceSource.cs
- ByteStreamGeometryContext.cs
- MatcherBuilder.cs
- _AutoWebProxyScriptHelper.cs
- AttributeQuery.cs
- WindowsTokenRoleProvider.cs
- SQLSingleStorage.cs
- UpdateTranslator.cs
- ReadOnlyCollectionBase.cs
- ProviderUtil.cs
- Timeline.cs
- ScriptReference.cs
- StreamInfo.cs
- SQLDecimal.cs
- IntPtr.cs
- ListViewContainer.cs
- GrowingArray.cs
- StringFormat.cs
- InvalidPipelineStoreException.cs
- ResponseBodyWriter.cs
- activationcontext.cs
- Point3DValueSerializer.cs
- XmlConvert.cs
- DecoderNLS.cs
- QueryExpr.cs
- DeploymentSection.cs