I have the following structure:
//function called from Node.js
public Task<object> NodeCall (IDictionary<string, object> payload) {
Func<object, Task<object>> changed = (Func<object, Task<object>>) payload["changed"];
return Task.Run (async () => await OnQuery (payload["request"], changed));
}
public async Task<object> OnQuery (dynamic request, dynamic payload = null) {
var result = new QueryCallback ();
//...code...
return result
}
In the code of "OnQuery" I should call a function of a singleton class and I need to queue the calls. The problem is that queuing I can't handle the thread response and awaiting the result the task send the reply.
My final result would be: put the task in the queue and when the singleton dequeue my task and finish the target function I return the result. In the while the OnQuery task should wait without returning anything.
Can someone help me with that?
Thanks
Edit 1 Servy signed as possible duplicate of this answer but I am not sure it can handle the result... If is it the right way can someone make a better sample please? It's not clear for me