小编Rom*_*kha的帖子

如何正确停止运行 dotnet core web 应用程序?

在 Windows 上的 Visual Studio 2017 和 2019 中,我dotnet watch run在包管理器控制台中运行。它为 dotnet 核心应用程序提供了 kestrel,自动禁用控制台中的文本编辑并显示红色按钮以停止命令执行,但该按钮不执行任何操作。此外,该消息正在显示以供使用,Ctrl+C但它也不起作用。

Now listening on: http://localhost:20436 Application started. Press Ctrl+C to shut down.
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试在 Visual Studio 中使用 Web 应用程序时出现错误,因为它已经在运行。我找不到像dotnet stopCtrl+C 这样的命令,它在这种情况下不起作用。我使用 Process Hacker 杀死了 dotnet.exe 进程,但这似乎不对。杀死正在运行的进程的最佳方法是什么?

visual-studio kestrel .net-core visual-studio-2017 visual-studio-2019

16
推荐指数
1
解决办法
2万
查看次数

?? 或 .GetValueOrDefault()

我有属性类型int?并且decimal?正在计算中使用。如果其中任何一个的值为 null,则必须默认为 0。我试图在使用 null-coalescing 或GetValueOrDefault()如果值为 时也默认为 0 之间做出决定null。哪种方法在可读性和性能方面更好(如果有任何明显的差异)?

第一的:

public decimal MyMethod(int memberId)
{ 
    var dto = GetDtoValue(memberId);
 return (dto.PropertyOne ?? 0)
      + (dto.PropertyTwo ?? 0)
      + (dto.PropertyThree ?? 0)
      - (dto.PropertyFour ?? 0)
      + ...
}
Run Code Online (Sandbox Code Playgroud)

第二:

public decimal MyMethod(int memberId)
    { 
        var dto = GetDtoValue(memberId);
     return dto.PropertyOne.GetValueOrDefault())
          + dto.PropertyTwo.GetValueOrDefault())
          + dto.PropertyThree.GetValueOrDefault())
          - dto.PropertyFour.GetValueOrDefault())
          + ...
    }
Run Code Online (Sandbox Code Playgroud)

.net c# operators null-coalescing

7
推荐指数
1
解决办法
3976
查看次数

从另一个管道触发 Azure DevOps 管道

我正在查看天蓝色触发器文档,但仍然无法找到合适的解决方案。在管道 1 执行过程中,如何触发管道 2,等待其成功完成或失败,并根据管道 2 的结果继续执行管道 1 或失败?

azure devops azure-devops azure-pipelines azure-pipelines-release-pipeline

5
推荐指数
1
解决办法
7365
查看次数