Activity.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / tx / System / Transactions / Trace / Activity.cs / 1305376 / Activity.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Transactions.Diagnostics 
{ 
    using System;
 
    internal class Activity : IDisposable
    {
        Guid oldGuid;
        Guid newGuid; 
        bool emitTransfer = false;
        bool mustDispose = false; 
 
        Activity(ref Guid newGuid, bool emitTransfer)
        { 
            this.emitTransfer = emitTransfer;
            if (DiagnosticTrace.ShouldCorrelate && newGuid != Guid.Empty)
            {
                this.newGuid = newGuid; 
                this.oldGuid = DiagnosticTrace.GetActivityId();
                if (oldGuid != newGuid) 
                { 
                    this.mustDispose = true;
                    if (this.emitTransfer) 
                    {
                        DiagnosticTrace.TraceTransfer(newGuid);
                    }
                    DiagnosticTrace.SetActivityId(newGuid); 
                }
            } 
        } 

        internal static Activity CreateActivity(Guid newGuid, bool emitTransfer) 
        {
            Activity retval = null;
            if (DiagnosticTrace.ShouldCorrelate &&
                (newGuid != Guid.Empty) && 
                (newGuid != DiagnosticTrace.GetActivityId()))
            { 
                retval = new Activity(ref newGuid, emitTransfer); 
            }
            return retval; 
        }

        public void Dispose()
        { 
            if (this.mustDispose)
            { 
                this.mustDispose = false; 
                if (this.emitTransfer)
                { 
                    DiagnosticTrace.TraceTransfer(oldGuid);
                }
                DiagnosticTrace.SetActivityId(oldGuid);
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Transactions.Diagnostics 
{ 
    using System;
 
    internal class Activity : IDisposable
    {
        Guid oldGuid;
        Guid newGuid; 
        bool emitTransfer = false;
        bool mustDispose = false; 
 
        Activity(ref Guid newGuid, bool emitTransfer)
        { 
            this.emitTransfer = emitTransfer;
            if (DiagnosticTrace.ShouldCorrelate && newGuid != Guid.Empty)
            {
                this.newGuid = newGuid; 
                this.oldGuid = DiagnosticTrace.GetActivityId();
                if (oldGuid != newGuid) 
                { 
                    this.mustDispose = true;
                    if (this.emitTransfer) 
                    {
                        DiagnosticTrace.TraceTransfer(newGuid);
                    }
                    DiagnosticTrace.SetActivityId(newGuid); 
                }
            } 
        } 

        internal static Activity CreateActivity(Guid newGuid, bool emitTransfer) 
        {
            Activity retval = null;
            if (DiagnosticTrace.ShouldCorrelate &&
                (newGuid != Guid.Empty) && 
                (newGuid != DiagnosticTrace.GetActivityId()))
            { 
                retval = new Activity(ref newGuid, emitTransfer); 
            }
            return retval; 
        }

        public void Dispose()
        { 
            if (this.mustDispose)
            { 
                this.mustDispose = false; 
                if (this.emitTransfer)
                { 
                    DiagnosticTrace.TraceTransfer(oldGuid);
                }
                DiagnosticTrace.SetActivityId(oldGuid);
            } 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK