[ui] Fix Quit method
This commit is contained in:
parent
080e3544ed
commit
9753c5d3c1
|
@ -26,6 +26,7 @@ namespace SparkleLib {
|
||||||
{
|
{
|
||||||
|
|
||||||
public IrcClient Client;
|
public IrcClient Client;
|
||||||
|
public Thread Thread;
|
||||||
public string Server;
|
public string Server;
|
||||||
public string Channel;
|
public string Channel;
|
||||||
public string Nick;
|
public string Nick;
|
||||||
|
@ -61,7 +62,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Thread thread = new Thread (
|
Thread = new Thread (
|
||||||
new ThreadStart (delegate {
|
new ThreadStart (delegate {
|
||||||
|
|
||||||
// Connect to the server
|
// Connect to the server
|
||||||
|
@ -80,7 +81,7 @@ namespace SparkleLib {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
thread.Start ();
|
Thread.Start ();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace SparkleLib {
|
||||||
private DateTime LastChange;
|
private DateTime LastChange;
|
||||||
private System.Object ChangeLock;
|
private System.Object ChangeLock;
|
||||||
private int FetchRequests;
|
private int FetchRequests;
|
||||||
|
private SparkleListener Listener;
|
||||||
|
|
||||||
public string Name;
|
public string Name;
|
||||||
public string RemoteName;
|
public string RemoteName;
|
||||||
|
@ -139,10 +140,10 @@ namespace SparkleLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Listen to the irc channel on the server
|
// Listen to the irc channel on the server
|
||||||
SparkleListener listener = new SparkleListener (Domain, "#" + RemoteName, UserEmail);
|
Listener = new SparkleListener (Domain, "#" + RemoteName, UserEmail);
|
||||||
|
|
||||||
// Stop polling when the connection to the irc channel is succesful
|
// Stop polling when the connection to the irc channel is succesful
|
||||||
listener.Client.OnConnected += delegate {
|
Listener.Client.OnConnected += delegate {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening...");
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ namespace SparkleLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
listener.Client.OnDisconnected += delegate {
|
Listener.Client.OnDisconnected += delegate {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Lost connection. Falling back to polling...");
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ namespace SparkleLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fetch changes when there is a message in the irc channel
|
// Fetch changes when there is a message in the irc channel
|
||||||
listener.Client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
|
Listener.Client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Was notified of a remote change.");
|
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Was notified of a remote change.");
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ namespace SparkleLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start listening
|
// Start listening
|
||||||
listener.Listen ();
|
Listener.Listen ();
|
||||||
|
|
||||||
|
|
||||||
// Keep a timer that checks if there are changes and
|
// Keep a timer that checks if there are changes and
|
||||||
|
@ -617,8 +618,11 @@ namespace SparkleLib {
|
||||||
public void Stop ()
|
public void Stop ()
|
||||||
{
|
{
|
||||||
|
|
||||||
RemoteTimer.Stop ();
|
RemoteTimer.Dispose ();
|
||||||
LocalTimer.Stop ();
|
LocalTimer.Dispose ();
|
||||||
|
|
||||||
|
Listener.Thread.Abort ();
|
||||||
|
Listener.Thread.Join ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,10 @@ namespace SparkleShare {
|
||||||
private void Quit (object o, EventArgs args)
|
private void Quit (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
foreach (SparkleRepo repo in SparkleUI.Repositories)
|
||||||
|
repo.Stop ();
|
||||||
|
|
||||||
|
|
||||||
// Remove the process id file
|
// Remove the process id file
|
||||||
File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid"));
|
File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, "sparkleshare.pid"));
|
||||||
Application.Quit ();
|
Application.Quit ();
|
||||||
|
|
Loading…
Reference in a new issue