How to make WCF RESTful service work async?

I create a WCF recreation service and this is a client. I plan that the client does not know much about the service, just the right URL to call the methods and the expected results.

My service contract:

[WebInvoke(Method="POST", UriTemplate="/tasks")] [OperationContract] void SubmitTask(Transaction task); [WebGet(UriTemplate = "/tasks/{taskId}")] [OperationContract] [XmlSerializerFormat] Transaction GetTask(string taskId); 

SubmitTask is implemented as follows:

 SubmitTask(Transaction task) { DoSomethingWithTask(task); task.Status = "SomeStatus"; DoSomethingElseWithTaks(task); task.Status = "SomeOtherStatus"; } 

What do I expect from a client:

 ButtonClick() { SubmitTask(task); while(true) { string status = Transaction GetTask(task.taskId).Status; Textbox.Text+= status; if(status==ok) break; Thread.Sleep(1000); } } 

The problem is that GetTask is not running on the service side and all SubmitTask operations are complete, so I only get the latest status of the task on the client side. How to implement asynchronos in this situation?

Thanks in advance!

+4
source share
1 answer

Have you read this interesting little article? Fine-tuning WCF to create a highly scalable asynchronous REST API and the next article, which is very good and which we hope will give you the answer Fix WCF to create a scalable asynchronous REST API

+1
source

Source: https://habr.com/ru/post/1481329/


All Articles