What would be (the closest) .NET Core 1.0 equivalent for
System.Threading.Thread.CurrentThread.ManagedThreadId
?
update
As @svick clarified System.Threading.Thread.CurrentThread.ManagedThreadId is at its usual location. Please see the screenshot below. The question is closed. (Still unclear how and when CurrentThread property's System.Threading.Thread instance is initialized to a non-null value (default(System.Threading.Thread) is always == null?) but this is not the subject of this topic.)
update 2
Actually System.Threading.Thread.CurrentThread.ManagedThreadId is available in .NET Core 1.0 application project, which has defined in its project.json:
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
and is missing in .NET Core 1.0 class library project, which has defined in its project.json:
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
How to make System.Threading.Thread.CurrentThread.ManagedThreadId available in .NET Core 1.0 class library project?
It's still the same: System.Threading.Thread.CurrentThread.ManagedThreadId
.
The Thread
class is in the System.Threading.Thread
package, which is included in Microsoft.NETCore.App
, but not in NETStandard.Library
. This means that Thread
will work out of the box in a .Net Core application, but to use it in a .Net Core library, you need to add "System.Threading.Thread": "4.0.0"
to "dependencies"
in your project.json.
For VS 2017 and .csproj based .NET Core projects, you'd add it to the .csproj:
<PackageReference Include="System.Threading.Thread" Version="4.0.0" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With