listener: add Dispose method

This commit is contained in:
Hylke Bons 2011-05-29 20:01:56 +01:00
parent adb6e4ba3c
commit e2d75a57fb
3 changed files with 10 additions and 4 deletions

View file

@ -95,7 +95,6 @@ namespace SparkleLib {
public abstract void Connect ();
public abstract void Announce (SparkleAnnouncement announcent);
public abstract void AlsoListenTo (string folder_identifier);
public abstract void Dispose ();
public abstract bool IsConnected { get; }
@ -104,11 +103,11 @@ namespace SparkleLib {
protected List<SparkleAnnouncement> queue_down = new List<SparkleAnnouncement> ();
protected bool is_connecting;
protected string server;
protected Timer reconnect_timer = new Timer { Interval = 60 * 1000};
protected Timer reconnect_timer = new Timer { Interval = 60 * 1000, Enabled = true };
public SparkleListenerBase (string server, string folder_identifier, NotificationServerType type) {
this.reconnect_timer.Elapsed += delegate {
if (!IsConnected && !IsConnecting)
if (!IsConnected && !this.is_connecting)
Reconnect ();
};
@ -185,6 +184,12 @@ namespace SparkleLib {
}
public virtual void Dispose ()
{
this.reconnect_timer.Dispose ();
}
public string Server {
get {
return this.server;

View file

@ -137,6 +137,7 @@ namespace SparkleLib {
{
this.thread.Abort ();
this.thread.Join ();
base.Dispose ();
}

View file

@ -77,7 +77,7 @@ namespace SparkleShare {
Font = NSFontManager.SharedFontManager.FontWithFamily
("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);
OpenLogs = new List <SparkleLog> ();
StatusIcon = new SparkleStatusIcon ();
}