Skip to content

Commit ea79e58

Browse files
committed
NLogTarget - Use FlushAsync instead of synchronous
1 parent e623c1b commit ea79e58

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## VNext
44
- [Populate required field Message with "n/a" if it is empty](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1066)
5+
- [NLog Target with support for specifying ConnectionString](https://github.com/microsoft/ApplicationInsights-dotnet/issues/2897)
56

67
## Version 2.22.0
78
- no changes since beta.

LOGGING/src/NLogTarget/ApplicationInsightsTarget.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,7 @@ protected override void FlushAsync(AsyncContinuation asyncContinuation)
187187

188188
try
189189
{
190-
this.TelemetryClient.Flush();
191-
if (DateTime.UtcNow.AddSeconds(-30) > this.lastLogEventTime)
192-
{
193-
// Nothing has been written, so nothing to wait for
194-
asyncContinuation(null);
195-
}
196-
else
197-
{
198-
// Documentation says it is important to wait after flush, else nothing will happen
199-
// https://docs.microsoft.com/azure/application-insights/app-insights-api-custom-events-metrics#flushing-data
200-
System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(500)).ContinueWith((task) => asyncContinuation(null));
201-
}
190+
this.TelemetryClient.FlushAsync(System.Threading.CancellationToken.None).ContinueWith(t => asyncContinuation(t.Exception));
202191
}
203192
catch (Exception ex)
204193
{

0 commit comments

Comments
 (0)