Client/MainForm.cs
author sl
Thu, 14 Aug 2014 00:23:18 +0200
changeset 21 274a6b27c3f9
parent 20 e3d394dd0388
child 25 6f10207a89a8
permissions -rw-r--r--
Adding server closing notification to clients.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 using System.ServiceModel;
    11 using System.ServiceModel.Channels;
    12 
    13 
    14 namespace SharpDisplayClient
    15 {
    16     public partial class MainForm : Form
    17     {
    18         ClientOutput iClientOutput;
    19         InstanceContext iInstanceContext;
    20         ClientInput iClientInput;
    21 
    22         public MainForm()
    23         {
    24             InitializeComponent();
    25         }
    26 
    27         private void buttonSetText_Click(object sender, EventArgs e)
    28         {
    29             //iClient.SetText(0,"Top");
    30             //iClient.SetText(1, "Bottom");
    31             iClientOutput.SetTexts(new string[] { "Top", "Bottom" });
    32         }
    33 
    34         private void MainForm_Load(object sender, EventArgs e)
    35         {
    36             iClientInput = new ClientInput();
    37             iInstanceContext = new InstanceContext(iClientInput);
    38             iClientOutput = new ClientOutput(iInstanceContext);
    39 
    40             iClientOutput.Connect("TestClient");
    41 
    42         }
    43 
    44         public void CloseConnection()
    45         {
    46             //If we close the instance context after the client output it hangs
    47             iInstanceContext.Close();
    48             iInstanceContext = null;
    49             iClientOutput.Close();
    50             iClientOutput = null;
    51             iClientInput = null;
    52         }
    53     }
    54 }