Client/Server duplex is still a mess in C#.
2 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using System.Windows.Forms;
7 using SharpDisplayInterface;
8 using System.ServiceModel;
9 using System.ServiceModel.Channels;
12 namespace SharpDisplayClient
17 public partial class Callback : IDisplayServiceCallback, IDisposable
19 public void OnConnected()
21 //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
22 //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
24 MessageBox.Show("OnConnected()", "Client");
28 public void OnServerClosing()
30 //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
31 //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
33 //MessageBox.Show("OnServerClosing()", "Client");
34 Program.iMainForm.CloseConnection();
35 Program.iMainForm.Close();
49 public partial class Client : DuplexClientBase<IDisplayService>
51 private string Name { get; set; }
53 public Client(InstanceContext callbackInstance)
54 : base(callbackInstance, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
57 public void Connect(string aClientName)
60 Channel.Connect(aClientName);
63 public void Disconnect()
65 Channel.Disconnect(Name);
69 public void SetText(int aLineIndex, string aText)
71 Channel.SetText(aLineIndex, aText);
75 public void SetTexts(System.Collections.Generic.IList<string> aTexts)
77 Channel.SetTexts(aTexts);