refactor: extract async API call into separate RunIt method and remove unused HttpClient
This commit is contained in:
+10
-7
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user