You can mixed both async/await and running on a background thread. Async/Await will not "affect" background thread anyhow. But please do remember, that underneath the async/await there are Task involved (and state machine).
Fun fact is - that when you decompile async/await code --> there is no async/await there;) You could say it is a syntax suger.
More info on how it is organised - for example here: https://ranjeet.dev/understanding-how-async-state-machine-works/
So it could happen, that when you return from the async operation (for example you will start receiving response from HTTP request) - it is possible you will end up on a different thread and the rest of the code will be processed on a different thread. Normally it is not an issue, but sometimes it does make a difference (for example on ASP.NET - httpcontext can be lost because of that)
You did ask also "how do i structure code" And that is the beauty of async/await. You don't :) All you have to change is to change everything to async/await - because the rule : "Async all the way" is very important" More on the important rules with asynchronous programing here:
https://learn.microsoft.com/en-us/archive/msdn-magazine/2013/march/async-await-best-practices-in-asynchronous-programming
So for example if you did have code like this:
public string SendHttpRequest()
{
using (var client = new WebClient())
{
return client.DownloadString(new Uri("http://www.example.com/example.aspx"));
}
}
you will just have to change it to:
public async Task<string> SendHttpRequestAsync()
{
using (var client = new WebClient())
{
return await client.DownloadStringTaskAsync("http://www.example.com/example.aspx");
}
}
And then of course each place in the code - you have to change to async (and you have to call this method and all method that will become async with await) That is the rule of "async all the way" Don't go into temptation to use it like this somewhere in the code:
SendHttpRequestAsync().Result --> beacause it saves you from adding async on the method;)
Then you miss the point of using asyncs and realy bed things can happen (try to do something like this in Winforms with some OnClick
event :) )