Skip to content
Discussion options

You must be logged in to vote

Refit returns a Task, so the actual HTTP call already runs off the calling thread - awaiting it does not block your main thread while the request is in flight. You generally do not need Task.Run for that.

A few options depending on what you actually want:

  • If you just want to free the UI/main thread while the call happens: await the Refit method directly. The continuation resumes on the captured context. If you do not need the captured context for post-processing, add ConfigureAwait(false) at the call site.

  • If you want all continuations to stay off the UI thread for an entire call chain, wrap the top-level call once: await Task.Run(() => api.HttpGet()). You do not need this per request.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by glennawatson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants