.net-core - System.Threading.Thread.CurrentThread.ManagedThreadId 的 .NET Core 1.0 等效项

标签 .net-core .net-standard .net-core-rc2

什么是(最接近的).NET Core 1.0 等效项

System.Threading.Thread.CurrentThread.ManagedThreadId 

?

更新

正如@svick 澄清的那样 System.Threading.Thread.CurrentThread.ManagedThreadId 位于其通常的位置。请看下面的截图。问题已结束。 (仍然不清楚 CurrentThread 属性的 System.Threading.Thread 实例如何以及何时初始化为非空值(default(System.Threading.Thread) 总是 == null?),但这不是本主题的主题。)

enter image description here

更新 2

实际上 System.Threading.Thread.CurrentThread.ManagedThreadId 在 .NET Core 1.0 应用程序项目中可用,该项目已在其 project.json 中定义:
"frameworks": {
  "netcoreapp1.0": {
  "imports": "dnxcore50"
}

并且在其 project.json 中定义的 .NET Core 1.0 类库项目中缺失:
"frameworks": {
  "netstandard1.6": {
   "imports": "dnxcore50"
}

如何使 System.Threading.Thread.CurrentThread.ManagedThreadId 在 .NET Core 1.0 类库项目中可用?

最佳答案

还是一样:System.Threading.Thread.CurrentThread.ManagedThreadId .
Thread类(class)在 System.Threading.Thread包,包含在 Microsoft.NETCore.App 中,但不在 NETStandard.Library .这意味着 Thread将在 .Net Core 应用程序中开箱即用,但要在 .Net Core 库中使用它,您需要添加 "System.Threading.Thread": "4.0.0""dependencies"在您的 project.json 中。

对于基于 VS 2017 和 .csproj 的 .NET Core 项目,您需要将其添加到 .csproj:

    <PackageReference Include="System.Threading.Thread" Version="4.0.0" />    

关于.net-core - System.Threading.Thread.CurrentThread.ManagedThreadId 的 .NET Core 1.0 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38080995/

相关文章:

asp.net-core - 模型集合上的 ModelBinding

msbuild - 无法在构建服务器上发布 ASP.NET Core 1.0 RC2 应用程序

asp.net-core - dnu 恢复在 Mac 上失败

c# - 网络核心: Find Application Assembly Location from Integration Test

c# - Azure 函数异常 - 将日志写入表存储时出错 : Microsoft. Azure.Cosmos.Table.StorageException

c# - .Net Standard 4.7.1 在序列化期间无法加载 System.Private.CoreLib

c# - 无法为 netstandard1.x 项目安装 Netstandard1.x Nuget 包

nuget - 减少对 .NET Standard 类库的依赖?

c# - 当构建 ".Net Standard"项目时 - 这意味着什么?