Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Update #283 - Fixed issue where connection could be opened/closed mul…
Browse files Browse the repository at this point in the history
…tiple times
  • Loading branch information
avanderhoorn committed Mar 27, 2013
1 parent 1dc893d commit fa75c96
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/Glimpse.Ado/AlternateType/GlimpseDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class GlimpseDbConnection : DbConnection
private IMessageBroker messageBroker;
private IExecutionTimer timerStrategy;
private TimeSpan timerTimeSpan;
private bool wasPreviouslyUsed;

public GlimpseDbConnection(DbConnection connection)
: this(connection, connection.TryGetProfiledProviderFactory())
Expand Down Expand Up @@ -218,6 +219,11 @@ private void StateChangeHaneler(object sender, StateChangeEventArgs args)

private void OpenConnection()
{
if (wasPreviouslyUsed)
{
ConnectionId = Guid.NewGuid();
}

timerTimeSpan = TimerTrigger();

MessageBroker.Publish(
Expand All @@ -227,6 +233,8 @@ private void OpenConnection()

private void ClosedConnection()
{
wasPreviouslyUsed = true;

MessageBroker.Publish(
new ConnectionClosedMessage(ConnectionId)
.AsTimedMessage(TimerStop(timerTimeSpan))
Expand Down

0 comments on commit fa75c96

Please sign in to comment.