refactor: extract async API call into separate RunIt method and remove unused HttpClient

This commit is contained in:
2024-12-16 21:45:16 +00:00
parent c97cae710e
commit a3cce3425f
16 changed files with 48 additions and 21 deletions
+10 -7
View File
@@ -8,11 +8,6 @@ using System.Threading.Tasks;
partial class Program {
private static readonly HttpClient client = new HttpClient(){
Timeout = TimeSpan.FromSeconds(10) // Set a timeout to avoid hanging
};
static async Task Main(string[] args){
Application.Init();
@@ -20,13 +15,21 @@ partial class Program {
window.SetDefaultSize(320,240);
window.DeleteEvent += (o,e) => Application.Quit();
string result = await DrApi.get_rants("https://devrant.com/feed/recent");
Console.WriteLine(result);
RunIt();
window.ShowAll();
Application.Run();
}
static async Task RunIt()
{
string result = await DrApi.get_rants("https://devrant.com/feed/recent").ConfigureAwait(false);
Console.WriteLine(result);
}
}