Svexo
Svexo

Reputation: 523

await async WCF method

I must be missing something obvious here. But I cant see wat I did wrong. I have the following code:

var resp = await client.findItemsByCategoryAsync(request);

But this code give me the following compiler error: enter image description here

Though it says awaitable I cannot use the await keyword. The method is provided by a WCF service (Ebay Finding API)

Upvotes: 3

Views: 591

Answers (1)

Pierre-Luc Pineault
Pierre-Luc Pineault

Reputation: 9201

The method containing the await operator must also be declared as async.

public async void YourMethodAsync()
{
     var resp = await client.findItemsByCategoryAsync(request);
}

The error message refers the current method, not the one you're calling await on.

Upvotes: 4

Related Questions