# HG changeset patch # User sl # Date 1408001414 -7200 # Node ID 6f10207a89a8d687cb871ebd2c13ed7fcfc6278a # Parent f442150ff735b3b58fd76ada5d42a0f2aefea806 Fixing hang when closing server with live client due to client instance context throwing an exception when closing. diff -r f442150ff735 -r 6f10207a89a8 Client/Client.cs --- a/Client/Client.cs Thu Aug 14 09:12:59 2014 +0200 +++ b/Client/Client.cs Thu Aug 14 09:30:14 2014 +0200 @@ -11,7 +11,10 @@ namespace SharpDisplayClient { - public partial class ClientInput : IDisplayServiceCallback + /// + /// + /// + public partial class ClientInput : IDisplayServiceCallback, IDisposable { public void OnConnected() { @@ -30,10 +33,18 @@ //MessageBox.Show("OnServerClosing()", "Client"); Program.iMainForm.CloseConnection(); } + + //From IDisposable + public void Dispose() + { + + } } - + /// + /// + /// public partial class ClientOutput : DuplexClientBase, IDisplayService { public ClientOutput(InstanceContext callbackInstance) diff -r f442150ff735 -r 6f10207a89a8 Client/MainForm.cs --- a/Client/MainForm.cs Thu Aug 14 09:12:59 2014 +0200 +++ b/Client/MainForm.cs Thu Aug 14 09:30:14 2014 +0200 @@ -16,7 +16,6 @@ public partial class MainForm : Form { ClientOutput iClientOutput; - InstanceContext iInstanceContext; ClientInput iClientInput; public MainForm() @@ -34,8 +33,9 @@ private void MainForm_Load(object sender, EventArgs e) { iClientInput = new ClientInput(); - iInstanceContext = new InstanceContext(iClientInput); - iClientOutput = new ClientOutput(iInstanceContext); + //Instance context is then managed by our client class + InstanceContext instanceContext = new InstanceContext(iClientInput); + iClientOutput = new ClientOutput(instanceContext); iClientOutput.Connect("TestClient"); @@ -43,9 +43,6 @@ public void CloseConnection() { - //If we close the instance context after the client output it hangs - iInstanceContext.Close(); - iInstanceContext = null; iClientOutput.Close(); iClientOutput = null; iClientInput = null; diff -r f442150ff735 -r 6f10207a89a8 Client/Program.cs --- a/Client/Program.cs Thu Aug 14 09:12:59 2014 +0200 +++ b/Client/Program.cs Thu Aug 14 09:30:14 2014 +0200 @@ -6,7 +6,7 @@ namespace SharpDisplayClient { - static class Program + static public class Program { public static MainForm iMainForm; @@ -14,7 +14,7 @@ /// The main entry point for the application. /// [STAThread] - static void Main() + static public void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff -r f442150ff735 -r 6f10207a89a8 Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Thu Aug 14 09:12:59 2014 +0200 +++ b/Server/MainForm.Designer.cs Thu Aug 14 09:30:14 2014 +0200 @@ -35,6 +35,8 @@ this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox(); this.panelDisplay = new System.Windows.Forms.Panel(); this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.checkBoxShowBorders = new System.Windows.Forms.CheckBox(); this.trackBarBrightness = new System.Windows.Forms.TrackBar(); this.buttonFill = new System.Windows.Forms.Button(); @@ -51,8 +53,7 @@ this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel(); - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); + this.buttonStartClient = new System.Windows.Forms.Button(); this.tabControl.SuspendLayout(); this.tabPageDisplay.SuspendLayout(); this.panelDisplay.SuspendLayout(); @@ -76,6 +77,7 @@ // // tabPageDisplay // + this.tabPageDisplay.Controls.Add(this.buttonStartClient); this.tabPageDisplay.Controls.Add(this.checkBoxReverseScreen); this.tabPageDisplay.Controls.Add(this.checkBoxConnectOnStartup); this.tabPageDisplay.Controls.Add(this.panelDisplay); @@ -202,6 +204,39 @@ this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); this.tableLayoutPanel.TabIndex = 5; // + // marqueeLabelTop + // + this.marqueeLabelTop.AutoEllipsis = true; + this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; + this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; + this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); + this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); + this.marqueeLabelTop.Name = "marqueeLabelTop"; + this.marqueeLabelTop.OwnTimer = false; + this.marqueeLabelTop.PixelsPerSecond = 64; + this.marqueeLabelTop.Separator = "|"; + this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30); + this.marqueeLabelTop.TabIndex = 2; + this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; + this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.marqueeLabelTop.UseCompatibleTextRendering = true; + // + // marqueeLabelBottom + // + this.marqueeLabelBottom.AutoEllipsis = true; + this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32); + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); + this.marqueeLabelBottom.Name = "marqueeLabelBottom"; + this.marqueeLabelBottom.OwnTimer = false; + this.marqueeLabelBottom.PixelsPerSecond = 64; + this.marqueeLabelBottom.Separator = null; + this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31); + this.marqueeLabelBottom.TabIndex = 3; + this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; + this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.marqueeLabelBottom.UseCompatibleTextRendering = true; + // // checkBoxShowBorders // this.checkBoxShowBorders.AutoSize = true; @@ -342,38 +377,15 @@ this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17); this.toolStripStatusLabelFps.Text = "FPS"; // - // marqueeLabelTop + // buttonStartClient // - this.marqueeLabelTop.AutoEllipsis = true; - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelTop.Location = new System.Drawing.Point(1, -124); - this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); - this.marqueeLabelTop.Name = "marqueeLabelTop"; - this.marqueeLabelTop.OwnTimer = false; - this.marqueeLabelTop.PixelsPerSecond = 64; - this.marqueeLabelTop.Separator = "|"; - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20); - this.marqueeLabelTop.TabIndex = 2; - this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789"; - this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.marqueeLabelTop.UseCompatibleTextRendering = true; - // - // marqueeLabelBottom - // - this.marqueeLabelBottom.AutoEllipsis = true; - this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -40); - this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); - this.marqueeLabelBottom.Name = "marqueeLabelBottom"; - this.marqueeLabelBottom.OwnTimer = false; - this.marqueeLabelBottom.PixelsPerSecond = 64; - this.marqueeLabelBottom.Separator = null; - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20); - this.marqueeLabelBottom.TabIndex = 3; - this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789"; - this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.marqueeLabelBottom.UseCompatibleTextRendering = true; + this.buttonStartClient.Location = new System.Drawing.Point(6, 282); + this.buttonStartClient.Name = "buttonStartClient"; + this.buttonStartClient.Size = new System.Drawing.Size(75, 23); + this.buttonStartClient.TabIndex = 15; + this.buttonStartClient.Text = "Start Client"; + this.buttonStartClient.UseVisualStyleBackColor = true; + this.buttonStartClient.Click += new System.EventHandler(this.buttonStartClient_Click); // // MainForm // @@ -427,6 +439,7 @@ public MarqueeLabel marqueeLabelBottom; private System.Windows.Forms.CheckBox checkBoxConnectOnStartup; private System.Windows.Forms.CheckBox checkBoxReverseScreen; + private System.Windows.Forms.Button buttonStartClient; } } diff -r f442150ff735 -r 6f10207a89a8 Server/MainForm.cs --- a/Server/MainForm.cs Thu Aug 14 09:12:59 2014 +0200 +++ b/Server/MainForm.cs Thu Aug 14 09:30:14 2014 +0200 @@ -11,7 +11,10 @@ using CodeProject.Dialog; using System.Drawing.Imaging; using System.ServiceModel; +using System.Threading; +// using SharpDisplayInterface; +using SharpDisplayClient; namespace SharpDisplayManager @@ -397,6 +400,12 @@ } } + private void buttonStartClient_Click(object sender, EventArgs e) + { + Thread clientThread = new Thread(SharpDisplayClient.Program.Main); + clientThread.Start(); + } + } diff -r f442150ff735 -r 6f10207a89a8 Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Thu Aug 14 09:12:59 2014 +0200 +++ b/Server/SharpDisplayManager.csproj Thu Aug 14 09:30:14 2014 +0200 @@ -90,6 +90,10 @@ + + {7ee64074-8cdb-4448-b40c-81b75d6b31cd} + SharpDisplayClient + {88eee0dc-abbc-4738-bad6-7e08cf7f50f9} SharpDisplayInterface