Client/MainForm.cs
author sl
Thu, 14 Aug 2014 09:30:14 +0200
changeset 25 6f10207a89a8
parent 21 274a6b27c3f9
child 26 a6fb2b2f73b0
permissions -rw-r--r--
Fixing hang when closing server with live client due to client instance context
throwing an exception when closing.
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@20
    19
        ClientInput iClientInput;
sl@18
    20
sl@18
    21
        public MainForm()
sl@18
    22
        {
sl@18
    23
            InitializeComponent();
sl@18
    24
        }
sl@18
    25
sl@18
    26
        private void buttonSetText_Click(object sender, EventArgs e)
sl@18
    27
        {
sl@19
    28
            //iClient.SetText(0,"Top");
sl@19
    29
            //iClient.SetText(1, "Bottom");
sl@20
    30
            iClientOutput.SetTexts(new string[] { "Top", "Bottom" });
sl@18
    31
        }
sl@18
    32
sl@18
    33
        private void MainForm_Load(object sender, EventArgs e)
sl@18
    34
        {
sl@20
    35
            iClientInput = new ClientInput();
sl@25
    36
            //Instance context is then managed by our client class
sl@25
    37
            InstanceContext instanceContext = new InstanceContext(iClientInput);
sl@25
    38
            iClientOutput = new ClientOutput(instanceContext);
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
            iClientOutput.Close();
sl@21
    47
            iClientOutput = null;
sl@21
    48
            iClientInput = null;
sl@21
    49
        }
sl@18
    50
    }
sl@18
    51
}