Reputation: 89
I'm writing a WCF service for an android application. The flow is pretty simple:
I suppose it has to be something with async task and threads that I never used in C#. Searching for a simple example I lost in sophisticated tutorials and rich opportunities what could be done with tasks and threads in C#. What is the best practice in this case? The very simple example would be very appreciated.
UPD. The service uses a Framework 4.0
Upvotes: 0
Views: 22673
Reputation: 63
I just found something simplified here.
i.e.
wcfObject objectFromService = await serviceClient.GetObjectByIDAsync(idParameter).ConfigureAwait(false);
Upvotes: 1
Reputation: 309
You can check this tutorials for .net 4.5:
http://www.codeproject.com/Articles/613678/Task-based-Asynchronous-Operation-in-WCF
http://jaliyaudagedara.blogspot.com/2013/03/asynchronous-operations-in-wcf.html
and the same qa:
Pattern for calling WCF service using async/await
good example:
https://github.com/BradRem/CslaAsyncWcfService
https://github.com/tomfaber/asyncdemo
https://github.com/kekekeks/AsyncRpc
https://github.com/devcurry/async-await-in-wcf
Update
for .net 4.0:
msdn.microsoft.com/en-us/library/ms731177(v=vs.100).aspx
it's old pattern but good for .net 4.0
msdn.microsoft.com/en-us/library/ms228963(v=vs.100).aspx
codeproject.com/Articles/14898/Asynchronous-design-patterns
example: github.com/mikehadlow/Mike.AsyncWcf
Upvotes: 7
Reputation: 456322
This doesn't have anything to do with async
.
The proper solution requires a reliable queue (e.g., an Azure queue) and an independent backend (e.g., an Azure worker role). When your app initially sends data to the WCF app, it should place it in the queue and return the result. The independent background worker then reads from the queue and does the actual processing.
Upvotes: 1