'await'运算符只能在异步方法中使用

时间:2018-05-18 23:12:14

标签: c# rest async-await

我不清楚当操作实际标记为异步时,为什么我收到此消息。

这是我的测试

public void TestMethod1()
   {

   SvcRestClient client =
            new SvcRestClient(new Uri("http://localhost:44395"),
                new AnonymousCredential());

   var tokenRequest = new TokenRequest
        {
            Username = "myusername",
            Password = "p@ssword1"
        };

   tokenRequest.Validate(); // passes

   var tokenResponse = await client.ApiRequestTokenPostWithHttpMessagesAsync(tokenRequest);  


    }

如果我尝试添加await,我会收到警告

enter image description here

1 个答案:

答案 0 :(得分:2)

您需要更改测试方法的签名以包含<class 'tensorflow.python.framework.ops.Operation'> <class 'dict'> {<tf.Tensor 'img_data:0' shape=(?, 64, 64, 3) dtype=float32>: array([[[[0.3019608 , 0.23921569, 0.58431375], [0.30588236, 0.23921569, 0.61960787], [0.30980393, 0.24705882, 0.63529414], ..., ,以便等待测试中的任务。

clearFilters(e: any): void {

    let num: number = this.getRandomNumber();
    if (num > 0 && num != this.clearDropdownSubject.getValue()) {
      this.clearDropdownSubject.next(num);
      this.filterInputList = [];
    }
    else {
      this.clearFilters(0);
    }
  }


  getRandomNumber(): number {
    let randomNumber: number = 0;
    return Math.floor(Math.random() * (100 - 1 + 1)) + 1;
  }