Have a scenario where we are measuring the cpu time in a C# async flow. What we are observing is that the thread id before a await and after await or not same.
As example we are getting the thread id using the following - NativeMethods.GetCurrentThreadId().
The code is as follows:
startThreadId = NativeMethods.GetCurrentThreadId()
var result = await ExecuteCommand();
endThreadId = NativeMethods.GetCurrentThreadId()
return result;
In the above code sample, the startThreadId and endThreadId are different and not matching. Any guidance on how to ensure that the thread id is same or it would never be the case with async await pattern ?
Thanks