Skip to content

Commit

Permalink
fix dispose bug
Browse files Browse the repository at this point in the history
  • Loading branch information
must21de authored and markusstoll committed Oct 15, 2015
1 parent 8ea9df0 commit c1988d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 10 additions & 5 deletions SparkleLib/SparkleListenerBase.cs
Expand Up @@ -71,14 +71,15 @@ public SparkleListenerBase (Uri server, string folder_identifier)
Server = server;
this.channels.Add (folder_identifier);

this.reconnect_timer.Elapsed += delegate {
if (!IsConnected && !IsConnecting)
Reconnect ();
};

this.reconnect_timer.Elapsed += OnTimerElapsed;
this.reconnect_timer.Start ();
}

private void OnTimerElapsed(object sender, EventArgs args)
{
if (!IsConnected && !IsConnecting)
Reconnect ();
}

public void Announce (SparkleAnnouncement announcement)
{
Expand Down Expand Up @@ -166,7 +167,11 @@ public virtual void Dispose ()
{
if (this.reconnect_timer != null) {
this.reconnect_timer.Stop ();

this.reconnect_timer.Elapsed -= OnTimerElapsed;
this.reconnect_timer.Dispose ();

this.reconnect_timer = null;
}
}

Expand Down
8 changes: 6 additions & 2 deletions SparkleLib/SparkleRepoBase.cs
Expand Up @@ -613,8 +613,12 @@ public void Resume (string message)

public void Dispose ()
{
this.remote_timer.Stop ();
this.remote_timer.Dispose ();
if (remote_timer != null) {
this.remote_timer.Elapsed -= RemoteTimerElapsedDelegate;
this.remote_timer.Stop ();
this.remote_timer.Dispose ();
this.remote_timer = null;
}

this.listener.Disconnected -= ListenerDisconnectedDelegate;
this.listener.AnnouncementReceived -= ListenerAnnouncementReceivedDelegate;
Expand Down

0 comments on commit c1988d6

Please sign in to comment.