// See https://aka.ms/new-console-template for more information using Gtk; using System; using System.Net.Http; using System.Threading.Tasks; partial class Program { private static readonly HttpClient client = new HttpClient(){ Timeout = TimeSpan.FromSeconds(10) // Set a timeout to avoid hanging }; public static async Task get(string url){ try { Console.WriteLine("SUCCESS\n " + url); HttpResponseMessage response = await client.GetAsync("https://google.nl"); Console.WriteLine("SUCCESS3\n " + url); if (response.IsSuccessStatusCode) { string responseData = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseData); return responseData; } else { Console.WriteLine("Error: " + response.StatusCode); } } catch (Exception ex) { Console.WriteLine("Exception occurred: " + ex.Message); } return "zzz"; } static async Task Main(string[] args){ Application.Init(); var window = new Window("My TEst"); window.SetDefaultSize(320,240); window.DeleteEvent += (o,e) => Application.Quit(); Console.WriteLine("DID TASK\n"); string result = await HttpHelper.GetContentsAsync("https://www.google.nl"); Console.WriteLine(result); //Console.WriteLine(await DrApi.get_rants("https://www.google.nl")); Console.WriteLine("DID TASK2\n"); window.ShowAll(); Application.Run(); } }