I try to understand also the async feature in the ver 4. Can you give me with very few words the meaning
The async in ver.4 is for server-side ?
Right now, all my client-side service calls, are async, using a pair of functions, as below. the async for ver .4 is for client ?
my client code
public static async void SaveIncident(IncidentRequest request, AsyncReturnDelegate onSavedIncident)
{
Incident incident = await SaveIncidentAsync(request);
onSavedIncident(incident);
}
static Task<Incident> SaveIncidentAsync(IncidentRequest request)
{
return Task.Run<Incident>(() => ServiceSaveIncident(request));
}
static Incident ServiceSaveIncident(IncidentRequest request)
{
IncidentResponse resp = client.ServicePost<IncidentResponse>(request); //wrapper to actual call
return resp.incident;
}
Note: server-side async is opaque and has nothing to do with client-side async. It just enables your service to now return a task, see these examples: http://bit.ly/1cOJ3hR
Stefan Tsalapatis:
I understood, thanks. Server side is very important, not-blocking ( it will be nice if we had some metrics). Also in client, ( I had not used before the asyncClient) my code is simplified a lot, only one function.
public static async void SaveIncident(IncidentRequest request, AsyncReturnDelegate onSavedIncident)
{
IncidentResponse resp = await asyncClient.PostAsync<IncidentResponse>(request);
onSavedIncident(resp.incident);
}