为什么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) 是否可以查看 Azure 应用服务的重启历史记录?
我的意思是在 GUI 中看到它,而不是 API。
history restart azure application-restart azure-web-app-service
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调用。
我正在处理一个 Visual Studio C# 项目,我需要知道它使用的是什么单元测试框架,但没有人询问。
我怎样才能检查它?
c# automated-tests unit-testing visual-studio visual-studio-2019
c# ×2
async-await ×1
azure ×1
csproj ×1
finally ×1
history ×1
javascript ×1
promise ×1
restart ×1
unit-testing ×1