小编hel*_*rld的帖子

为什么在C#方法中我们需要多个`await`语句?

为什么await在C#方法中我们需要多个语句?

例如,这里有三个await语句:

using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;

namespace Acme.BookStore
{
    public class BookStoreDataSeederContributor
        : IDataSeedContributor, ITransientDependency
    {
        private readonly IRepository<Book, Guid> _bookRepository;

        public BookStoreDataSeederContributor(IRepository<Book, Guid> bookRepository)
        {
            _bookRepository = bookRepository;
        }

        public async Task SeedAsync(DataSeedContext context)
        {
            if (await _bookRepository.GetCountAsync() > 0)
            {
                return;
            }

            await _bookRepository.InsertAsync(
                new Book
                {
                    Name = "1984",
                    Type = BookType.Dystopia,
                    PublishDate = new DateTime(1949, 6, 8),
                    Price = 19.84f
                }
            );

            await _bookRepository.InsertAsync( …
Run Code Online (Sandbox Code Playgroud)

c# async-await

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

是否可以查看 Azure 应用服务的重启历史记录?

是否可以查看 Azure 应用服务的重启历史记录?

我的意思是在 GUI 中看到它,而不是 API。

history restart azure application-restart azure-web-app-service

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

.csproj 中的 &lt;SubType&gt;Designer&lt;/SubType&gt; 是什么?

.csproj 中的 Designer 有什么用?

我找到了这篇文章,但是指向某种文档的链接在那里被破坏了,所以我无法阅读这是什么。

有人可以提供 SubType 的定义吗?也许更深入的解释。

csproj visual-studio visual-studio-2019

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

js Promise 上下文中的finally 何时被调用?

js Promise 上下文中的finally 何时被调用?

我一开始以为 thefinally会在最后一个之后被调用then。但后来我明白了,最后的决定是不可能的then。我的下面的尝试也证明了这一点:

function f(resolve, reject) {
    resolve("foo");
};
var p = new Promise(f);
p.then(function(data) {
     console.log("data: " + data); 
});
p.finally(function(data) {
     console.log("in finally");
});
p.then(function(data) {
     console.log("data: " + data); 
});
Run Code Online (Sandbox Code Playgroud)

输出:

data: foo
in finally
data: foo
Run Code Online (Sandbox Code Playgroud)

因此,finally在最后一个之后不会调用then。我认为应该在thenfinally之后调用thethe resolve。但在我上面尝试的示例代码中,我们可以看到情况也并非如此(因为注册then是在resolve和 之间调用的finally)。

因此,我很困惑,不明白什么时候会被finally调用。

javascript finally promise

3
推荐指数
1
解决办法
2570
查看次数

如何识别Visual Studio、.NET项目中使用的单元测试框架?

我正在处理一个 Visual Studio C# 项目,我需要知道它使用的是什么单元测试框架,但没有人询问。

我怎样才能检查它?

c# automated-tests unit-testing visual-studio visual-studio-2019

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