Marcel
Marcel

Reputation: 927

Servicestack getAsync explanation

I'm quite new to webservices and rest, and I'm currently playing around with servicestack.

I have the following code, which works:

var response = client.Get<MeasurementResult>(SettingsManager.getMeasurementPath(1));
Measurement measurement = response.result;

I want to solve this asynchronously, but I don't really understand the documentation on this. http://docs.servicestack.net/csharp-client

How can I achieve the above shown example wit getAsync instead of get? My main problem is the submission of the address.

Upvotes: 1

Views: 349

Answers (1)

Kenneth
Kenneth

Reputation: 28747

You need to use the async / await modifiers on your code (and mark the containing method as async as well):

async Measurement GetMeasurement()
{
    var response = await client.GetAsync<MeasurementResult>(SettingsManager.getMeasurementPath(1)));
    return response.Result;
}

Upvotes: 3

Related Questions