[英]Why I cannot "await" an Async method from Atlassian SDK?
I am desperately trying to run the following code:我拼命地尝试运行以下代码:
var ad = jira.Issues.GetIssuesFromJqlAsync("PROJECT = MyProject AND ISSUETYPE = DEFECT");
The signature of the method is Task<IPagedQueryResult<Issue>>
( documentation link )该方法的签名是
Task<IPagedQueryResult<Issue>>
( 文档链接)
The method should be async but I cannot use "await" (I get the error that the method needs to be marked with async and return task..).该方法应该是异步的,但我不能使用“await”(我收到错误,该方法需要用异步标记并返回任务..)。 I am able to execute it by calling
ad.start()
but that is not asynchronous.我可以通过调用
ad.start()
来执行它,但这不是异步的。 What can I do to fix this?我能做些什么来解决这个问题?
mark you method Async.标记你的方法异步。 if you dont need the return it dosnt need to be a task,
如果你不需要回报,它不需要是一项任务,
it should look like:它应该看起来像:
public async Task<string> YourMethod()
{
var ad = await jira.Issues.GetIssuesFromJqlAsync("PROJECT = MyProject AND ISSUETYPE = DEFECT");
return ad.ToString();
}
if you want the return, or:如果您想要退货,或者:
async Task MyMethodAsync()
{
var ad = await jira.Issues.GetIssuesFromJqlAsync("PROJECT = MyProject AND ISSUETYPE = DEFECT");
}
for a more in depth explanation here are the docs...对于更深入的解释,这里是文档......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.