private TaskCompletionSource response;
private string _text = \"\";
public void SetResult(bool result)
{
this.response.SetResult(res
If the response is not set, it will wait until it's set and will not return anything until it's set. It also has to be asychronous.
Those two requirements are the exact opposite of each other.
If you need to wait until the result is available, then you need it to be synchronous (that's the definition of synchronous). There are various hacks that can make this work - calling Result
is one of them.
If you need it to be asynchronous, then you can't wait until the result is available. In that case you should look into creating a JavaScript promise/deferred object and notify that object when the result arrives.