diff --git a/src/Backend.cs b/src/Backend.cs index aa443e9..b302473 100644 --- a/src/Backend.cs +++ b/src/Backend.cs @@ -110,5 +110,12 @@ namespace WorldOfPeacecraft { Gui.PerformRefresh(); } + + public void Stop() { + Parse.Stop (); + Send.Stop (); + Rec.Stop (); + System.Windows.Forms.Application.Exit (); + } } } diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index 8adfd09..6121d8f 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -42,6 +42,12 @@ namespace WorldOfPeacecraft this.PerformLayout(); } + protected override void OnClosing (System.ComponentModel.CancelEventArgs e) + { + base.OnClosing (e); + Backend.Stop (); + } + public void DoPaint (object source, PaintEventArgs args) { BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate (Board.CreateGraphics (), Board.DisplayRectangle); diff --git a/src/Gui/IBackend.cs b/src/Gui/IBackend.cs index 1ec4fc5..85fe8cb 100644 --- a/src/Gui/IBackend.cs +++ b/src/Gui/IBackend.cs @@ -4,5 +4,7 @@ namespace WorldOfPeacecraft public interface IBackend { ITile[,] GetMap(); + + void Stop(); } } diff --git a/src/Sender.cs b/src/Sender.cs index 93b1ce0..72252e4 100644 --- a/src/Sender.cs +++ b/src/Sender.cs @@ -34,7 +34,7 @@ namespace WorldOfPeacecraft } } - public void stop() + public void Stop() { SenderThread.Abort(); }