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