Trying to write an API, and I have a weird case which I tried to solve like:
if (!request.WillCheckGetLater)
{
// Client calling is willing to wait only for certain amount of time
var clientWillingToWaitFor = GetResponseTime(request);
var needsToUpdateResponse = await AwaitResponse(heldBidRequest, clientWillingToWaitFor);
SendMessage(...);
return needsToUpdateResponse;
}
else
{
SendMessage(...);
return false;
}
While on my Post method I'm trying to await that method. Basically when I get a post, I construct a "short" answer, and the client check the "long" answer with the GET method from the API, but can also ask directly for the long answer in the POST, but has to specify how much he's willing to wait for that long answer, otherwise I default to a "short" answer...
My SendMessage method is basically third party communication system where I subscribe and publish messages.
right now, when the line
var needsToUpdateResponse = await AwaitResponse(heldBidRequest, clientWillingToWaitFor);
executes, it blocks this piece of code and SendMessage doesn't execute until the task over, ideally I would rather have it blocked on the return instead.
I don't necessary want to call SendMessage First just because of the weird scenario I could get that the response from the message comes before I set up for waiting for it.
Any ideas of what I could use to do that?