C#中的异步/等待问题

时间:2019-06-11 12:40:51

标签: asynchronous async-await

我在C#中使用async / await方法...我的操作是在Azure Cosmos DB上创建数据库,问题是代码在运行时由于某种原因而运行...流程显然没有任何问题< / p>

有人可以帮忙吗?

Task p= Run();

public async static Task Run()
{
    .
    .
    .
    await CreateDatabase(client)
}

private async static Task CreateDatabase(DocumentClient client)
{
    var databaseDefinition = new Database { Id = "MyDB" };
    var result = await client.CreateDatabaseAsync(databaseDefinition);
    var database = result.Resource;
}

//In second line, the code brake when the debugging is operating

//==> var result = await client.CreateDatabaseAsync(databaseDefinition);

0 个答案:

没有答案