Removes AppDomain dependency from TPLETWProvider (#21709)
authorMarek Safar <marek.safar@gmail.com>
Fri, 4 Jan 2019 15:06:00 +0000 (16:06 +0100)
committerJan Kotas <jkotas@microsoft.com>
Fri, 4 Jan 2019 15:06:00 +0000 (05:06 -1000)
which always returns 1, to make code sharing easier

src/System.Private.CoreLib/src/System/Threading/Tasks/TPLETWProvider.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs

index 401ae40..6c28ba5 100644 (file)
@@ -33,6 +33,8 @@ namespace System.Threading.Tasks
         internal bool Debug;
         private bool DebugActivityId;
 
+        private const int DefaultAppDomainID = 1;
+
         /// <summary>
         /// Get callbacks when the ETW sends us commands`
         /// </summary>
@@ -219,7 +221,7 @@ namespace System.Threading.Tasks
          Level = EventLevel.Informational, Keywords = Keywords.TaskTransfer | Keywords.Tasks)]
         public void TaskScheduled(
             int OriginatingTaskSchedulerID, int OriginatingTaskID,  // PFX_COMMON_EVENT_HEADER
-            int TaskID, int CreatingTaskID, int TaskCreationOptions, int appDomain)
+            int TaskID, int CreatingTaskID, int TaskCreationOptions, int appDomain = DefaultAppDomainID)
         {
             // IsEnabled() call is an inlined quick check that makes this very fast when provider is off 
             if (IsEnabled() && IsEnabled(EventLevel.Informational, Keywords.TaskTransfer | Keywords.Tasks))
@@ -583,9 +585,8 @@ namespace System.Threading.Tasks
             // using the last 8 bytes  as the provider GUID for this provider.  
             // These were generated by CreateGuid, and are reasonably random (and thus unlikley to collide
             uint pid = EventSource.s_currentPid;
-            int appDomainID = System.Threading.Thread.GetDomainID();
             return new Guid(taskID,
-                            (short)appDomainID, (short)(appDomainID >> 16),
+                            (short)DefaultAppDomainID, (short)(DefaultAppDomainID >> 16),
                             (byte)pid, (byte)(pid >> 8), (byte)(pid >> 16), (byte)(pid >> 24),
                             0xff, 0xdc, 0xd7, 0xb5);
         }
index c3a4af3..1061c8b 100644 (file)
@@ -890,8 +890,7 @@ namespace System.Threading.Tasks
                 Task currentTask = Task.InternalCurrent;
                 Task parentTask = m_contingentProperties?.m_parent;
                 etwLog.TaskScheduled(ts.Id, currentTask == null ? 0 : currentTask.Id,
-                                     this.Id, parentTask == null ? 0 : parentTask.Id, (int)this.Options,
-                                     System.Threading.Thread.GetDomainID());
+                                     this.Id, parentTask == null ? 0 : parentTask.Id, (int)this.Options);
                 return true;
             }
             else