microsoft / microsoft/ApplicationInsights-dotnet

Flush doesn't block until messages are actually flushed

Open
#407 53 comments 60 reactions 1 assignee View on GitHub

@rajkumar-rangaraj is already working on this.

Since Mar 12, 2026.

3.x enhancement keep-open
Dominant language
C#
Stars
613
Forks
301
PR merge metrics
No merged PRs in 30d

Description

TelemetryClient.Flush() doesn't actually block returning until the messages are flushed. This means if you're want to flush messages during application shutdown (like in Microsoft/ApplicationInsights-aspnetcore#304) then you have to add a Thread.Sleep(1000) which isn't ideal.

It would be nice if there was a blocking version of this API that took an optional timeout, such that it only blocked for the time necessary to flush the events, or the timeout is hit, so that application shutdown doesn't have to be blocked any longer than necessary.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.