0

As answered here, its enough to return a Task to make a ServiceStack service method async.

If I manually invoke a Service, as described here, I only have a non-awaitable ExecuteMessage, and no ExecuteMessageAsync. There is, in contrast, a method HostContext.AppHost.ExecuteServiceAsync.

  • Is there a reason for the lacking ExecuteMessageAsync?
  • I could do like await Task.Run(() => ExecuteMessage(...)), but it doesn't seem right to me.

Any input would be appreciated!

Ted
  • 19,727
  • 35
  • 96
  • 154
  • Why would you run a sync method in a new Thread just to await it again? i.e. What does the added inefficiency over calling the method normally suppose to achieve? – mythz Oct 30 '20 at 16:18
  • Well, no reason really, its just that the method was async and compiler warned. I can remove `async`and just use `HostContext.AppHost.ExecuteMessage(theMessage); return Task.CompletedTask;` instead, but, yeah, no reason really. – Ted Oct 30 '20 at 19:34

1 Answers1

0

ExecuteMessageAsync didn't exist because it's not needed or used by any of ServiceStack MQ providers. But I've just added Async versions of the ExecuteMessage APIs to both ServiceStack AppHost and its ServiceController.

This change is available from the latest v5.9.3+ that's now available on MyGet.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • Can I also ask if there is any news on this one: https://servicestack.uservoice.com/forums/176786-feature-requests/suggestions/5701744-provide-async-support-for-redis-client – Ted Oct 30 '20 at 19:38
  • 1
    @Ted Redis Async support is already available in v5.9.3+, access it with `using var client = redisManager.GetClientAsync()` from your Redis Client Manager or in your Service `using var client = base.GetRedisClientAsync()` in your `Service`. Requires .NET Core or .NET v4.7.2+. – mythz Oct 30 '20 at 19:51
  • Oh, great. Im getting some weird 503 errors, but I'll work em out and install 5.9.3. Thanks again. – Ted Oct 30 '20 at 19:55