I have a azure function connected to a singnalr service that why IAsyncCollector paramter is used to add the return via AddAsync. Now I have to call a async method to calculate the result but so I need to change the method signature to async but then I also have to change the result to Task what is not working at runtime.
[FunctionName("Join")]
public static async Task<Task> Join(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] JoinRequest message,
[SignalR(HubName = "chat")] IAsyncCollector<SignalRMessage> signalRMessages)
{
await MyHelper.Instance.FillAsync(message);
return signalRMessages.AddAsync(
new SignalRMessage
{
Target = "joined",
Arguments = new[] { message }
});
}
I read about how IAsyncCollector collector work, so awaitig AddAsync make no sense. But how can I call that async method or make IAsyncCollector work in an async method. I not really found some sample how this may work. There are some samples in ms doc but they have no return or do not use async.