Skip to content

Commit

Permalink
Close channel after usage
Browse files Browse the repository at this point in the history
closes #378
  • Loading branch information
kichristensen committed Aug 4, 2014
1 parent b151950 commit 138fd2e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/NLog/Targets/LogReceiverWebServiceTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace NLog.Targets
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
#if WCF_SUPPORTED
using System.ServiceModel;
Expand Down Expand Up @@ -335,8 +336,20 @@ protected virtual WcfLogReceiverClient CreateWcfLogReceiverClient()
{
client = new WcfLogReceiverClient(this.EndpointConfigurationName, new EndpointAddress(this.EndpointAddress));
}

client.ProcessLogMessagesCompleted += ClientOnProcessLogMessagesCompleted;

return client;
}

private void ClientOnProcessLogMessagesCompleted(object sender, AsyncCompletedEventArgs asyncCompletedEventArgs)
{
var client = sender as WcfLogReceiverClient;
if (client != null && client.State == CommunicationState.Opened)
{
client.Close();
}
}
#endif

private void SendBufferedEvents()
Expand Down

1 comment on commit 138fd2e

@pjdupreez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks!

Please sign in to comment.