Mercurial > hg > Database > Christie-sharp
changeset 62:12b7528000da
fix Thread to Task
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 29 Jan 2022 15:08:13 +0900 |
parents | 1a42115e51bb |
children | 960fc3820613 |
files | daemon/AcceptThread.cs daemon/ChristieDaemon.cs unitypakage/Christie_net.unitypackage |
diffstat | 3 files changed, 4 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/daemon/AcceptThread.cs Fri Jan 28 23:15:05 2022 +0900 +++ b/daemon/AcceptThread.cs Sat Jan 29 15:08:13 2022 +0900 @@ -2,6 +2,7 @@ using System.Net; using System.Net.Sockets; using System.Threading; +using System.Threading.Tasks; using Christie_net.codegear; namespace Christie_net.daemon { @@ -31,16 +32,12 @@ string key = "accept" + counter; IncomingTcpConnection incoming = new IncomingTcpConnection(connection); - Thread incomingThread = new Thread(incoming.Run); - incomingThread.Name = connection.GetInfoString() + "-IncomingTcp"; - incomingThread.Start(); + Task.Factory.StartNew(() => incoming.Run()); cgm.SetAccept(key, incoming); OutboundTcpConnection outbound = new OutboundTcpConnection(connection); - Thread outboundThread = new Thread(outbound.Run); - outboundThread.Name = connection.GetInfoString() + "-OutboundTcp"; - outboundThread.Start(); + Task.Factory.StartNew(() => outbound.Run()); counter++; } catch (Exception e) { Console.WriteLine(e.StackTrace);
--- a/daemon/ChristieDaemon.cs Fri Jan 28 23:15:05 2022 +0900 +++ b/daemon/ChristieDaemon.cs Sat Jan 29 15:08:13 2022 +0900 @@ -32,9 +32,7 @@ listener.Start(); acceptThread = new AcceptThread(listener, cgm); - Thread thread = new Thread(acceptThread.Run); - thread.Name = ("ACCEPT" + localPort); - thread.Start(); + Task.Factory.StartNew(() => acceptThread.Run()); } catch (Exception e) { Console.WriteLine(e.StackTrace);