According to documentation http://msdn.microsoft.com/en-us/library/dn775009%28v=pandp.20%29.aspx current activity id should be handled by TPL. But when I get results, log events from different tasks belong to different activities.
To read messages I use out of process SemanticLogging-svc.2.0.1406.1
Workflow is follow:
1. I set activity id, which shall be used. EventSource.SetCurrentThreadActivityId.
2. Then I have some code in same thread, but also can be a lot of code in different threads. Example (log messages from below tasks are logged as different activity ids):
Events.Current.TestMethod3();
Task.WaitAll(Task.Factory.StartNew(() =>
{
for (int i = 0; i < 10; i++)
{
Events.Current.TestMethod1_Sleep(50);
System.Threading.Thread.Sleep(50);
Events.Current.TestMethod2_Continue();
}
}),
Task.Factory.StartNew(() =>
{
for (int i = 0; i < 10; i++)
{
Events.Current.TestMethod1_Sleep(60);
System.Threading.Thread.Sleep(60);
Events.Current.TestMethod2_Continue();
}
}));
Events.Current.TestMethod3();
Any ideas how to solve that? Maybe I shall do special things to solve that?