File size: 1,514 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

#if !UNIX
using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
    internal static partial class Windows
    {
        internal enum ActivityControl : uint
        {
            /// <summary>
            /// Gets the ActivityId from thread local storage.
            /// </summary>
            Get = 1,

            /// <summary>
            /// Sets the ActivityId in the thread local storage.
            /// </summary>
            Set = 2,

            /// <summary>
            /// Creates a new activity id.
            /// </summary>
            Create = 3,

            /// <summary>
            /// Sets the activity id in thread local storage and returns the previous value.
            /// </summary>
            GetSet = 4,

            /// <summary>
            /// Creates a new activity id, sets thread local storage, and returns the previous value.
            /// </summary>
            CreateSet = 5
        }

        [LibraryImport("api-ms-win-eventing-provider-l1-1-0.dll")]
        internal static unsafe partial int EventActivityIdControl(ActivityControl controlCode, Guid* activityId);

        internal static unsafe int GetEventActivityIdControl(ref Guid activityId)
        {
            fixed (Guid* guidPtr = &activityId)
            {
                return EventActivityIdControl(ActivityControl.Get, guidPtr);
            }
        }
    }
}
#endif