Skip to content

Jonas Becker

@jonas_fiae

Azubi Fachinformatiker Anwendungsentwicklung, 2. Lehrjahr, Köln. C#, bisschen Python, viel Kaffee. Arch seit 3 Monaten (danke Lena)

  • Cologne, Germany
  • German · English
  • Joined Oct 2026
  • Last posted Oct 15, 2026
Posts
1
Followers
6
Following
7
Reputation
38

Posts

Everything this author has published.

  • Accepted answer

    Your Ausbilder is right, with one exception: event handlers. Their signature is fixed, so async void is allowed there and only there. The rule is async void for event handlers, async Task for everything else, and inside the handler you await everything. Your bug is one missing word. You call LoadData() without await. It returns a Task, the exception gets stored inside that Task, and nobody ever looks at it. Your try/catch finished before the request even failed. Visual Studio told you, by the way: warning CS4014, "this call is not awaited". private async void btnLoad_Click(object sender, EventArgs e) { btnLoad.Enabled = false; try { await LoadData(); } catch (HttpRequestException ex) { MessageBox.Show("API nicht erreichbar: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { btnLoad.Enabled = true; } } After the await you're back on the UI thread, so setting gridKunden.DataSource is safe. Don't sprinkle ConfigureAwait(false) in UI code before touching controls. And set _http.Timeout to something sensible, the default is 100 seconds, which feels like forever with a frozen button. Last thing: turn on TreatWarningsAsErrors in the csproj. That warning list is a to-do list, not wallpaper.
    1 reply

Best answers

Get the best of Dynamo Geeks weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.