Mercurial > hg > Database > Christie-sharp
comparison daemon/AcceptThread.cs @ 62:12b7528000da
fix Thread to Task
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 29 Jan 2022 15:08:13 +0900 |
parents | dc3f59937772 |
children | 058d41dcec41 |
comparison
equal
deleted
inserted
replaced
61:1a42115e51bb | 62:12b7528000da |
---|---|
1 using System; | 1 using System; |
2 using System.Net; | 2 using System.Net; |
3 using System.Net.Sockets; | 3 using System.Net.Sockets; |
4 using System.Threading; | 4 using System.Threading; |
5 using System.Threading.Tasks; | |
5 using Christie_net.codegear; | 6 using Christie_net.codegear; |
6 | 7 |
7 namespace Christie_net.daemon { | 8 namespace Christie_net.daemon { |
8 public class AcceptThread { | 9 public class AcceptThread { |
9 private TcpListener listener; | 10 private TcpListener listener; |
29 Connection connection = new Connection(client.Client, cgm); | 30 Connection connection = new Connection(client.Client, cgm); |
30 Console.WriteLine("connection:" + connection.GetInfoString()); | 31 Console.WriteLine("connection:" + connection.GetInfoString()); |
31 string key = "accept" + counter; | 32 string key = "accept" + counter; |
32 | 33 |
33 IncomingTcpConnection incoming = new IncomingTcpConnection(connection); | 34 IncomingTcpConnection incoming = new IncomingTcpConnection(connection); |
34 Thread incomingThread = new Thread(incoming.Run); | 35 Task.Factory.StartNew(() => incoming.Run()); |
35 incomingThread.Name = connection.GetInfoString() + "-IncomingTcp"; | |
36 incomingThread.Start(); | |
37 | 36 |
38 cgm.SetAccept(key, incoming); | 37 cgm.SetAccept(key, incoming); |
39 | 38 |
40 OutboundTcpConnection outbound = new OutboundTcpConnection(connection); | 39 OutboundTcpConnection outbound = new OutboundTcpConnection(connection); |
41 Thread outboundThread = new Thread(outbound.Run); | 40 Task.Factory.StartNew(() => outbound.Run()); |
42 outboundThread.Name = connection.GetInfoString() + "-OutboundTcp"; | |
43 outboundThread.Start(); | |
44 counter++; | 41 counter++; |
45 } catch (Exception e) { | 42 } catch (Exception e) { |
46 Console.WriteLine(e.StackTrace); | 43 Console.WriteLine(e.StackTrace); |
47 } | 44 } |
48 } | 45 } |