I'm trying to write a C# console application that uses HttpClient to scrape web pages. When FunctionOne is called, what's the best way to ensure that "A" is written to the console before "B"? Whenever I run my code, "B" is always written before "A". Thanks in advance for the help!
public class MyClass
{
public void FunctionOne(string url)
{
FunctionTwoAsync(url);
Console.WriteLine("B");
}
private async void FunctionTwoAsync(string url)
{
var httpClient = new HttpClient();
var htmlContent = await httpClient.GetStringAsync(url);
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(htmlContent);
Console.WriteLine("A");
}
}