diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/SparkleListenerTcp.cs index 6f464c13..15268a94 100755 --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/SparkleListenerTcp.cs @@ -130,6 +130,7 @@ namespace SparkleLib { public override void AlsoListenTo (string folder_identifier) { string channel = folder_identifier; + if (!base.channels.Contains (channel)) { base.channels.Add (channel); @@ -139,13 +140,13 @@ namespace SparkleLib { string to_send = "subscribe " + folder_identifier + "\n"; try { - lock (this.mutex) { this.socket.Send (Encoding.UTF8.GetBytes (to_send)); } + } catch (SocketException e) { - SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message); - OnDisconnected (); + SparkleHelpers.DebugInfo ("ListenerTcp", "Could not connect to " + Server + ": " + e.Message); + OnDisconnected (); } } } diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 67dfd2d0..16e82f68 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -21,6 +21,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using System.Timers; using System.Xml; @@ -41,10 +42,10 @@ namespace SparkleLib { private SparkleWatcher watcher; private TimeSpan poll_interval; - private Timer local_timer = new Timer () { Interval = 0.25 * 1000 }; - private Timer remote_timer = new Timer () { Interval = 10 * 1000 }; + private System.Timers.Timer local_timer = new System.Timers.Timer () { Interval = 0.25 * 1000 }; + private System.Timers.Timer remote_timer = new System.Timers.Timer () { Interval = 10 * 1000 }; private DateTime last_poll = DateTime.Now; - private List sizebuffer = new List (); + private List sizebuffer = new List (); private bool has_changed = false; private Object change_lock = new Object (); @@ -236,8 +237,10 @@ namespace SparkleLib { if (this.listener.IsConnected) { this.poll_interval = this.long_interval; - if (!IsSyncing && CheckForRemoteChanges ()) - SyncDownBase (); + new Thread (new ThreadStart (delegate { + if (!IsSyncing && CheckForRemoteChanges ()) + SyncDownBase (); + })).Start (); } // Stop polling when the connection to the irc channel is succesful