view daemon/ThreadPoolExecutors.cs @ 47:61ec3dd0995c

bug fixing
author riono <e165729@ie.u-ryukyu.ac.jp>
date Mon, 10 Jan 2022 00:45:32 +0900
parents 96fc5e71274e
children ef3fd58af531
line wrap: on
line source

using System.Threading;
using System.Threading.Tasks;
using Christie_net.codegear;

namespace Christie_net.daemon {
public class ThreadPoolExecutors {

    // TODO: どこかしらでThreadPoolの設定をする
    public ThreadPoolExecutors() {
        int nWorkerThreads;
        int nIOThreads;
        ThreadPool.GetMinThreads(out nWorkerThreads, out nIOThreads);
        ThreadPool.SetMinThreads(nWorkerThreads, nIOThreads);
    }
    
    public ThreadPoolExecutors(int nWorkerThreads, int nIOThreads) {
        ThreadPool.SetMinThreads(nWorkerThreads, nIOThreads);
    }
    
    public void Execute(CodeGearExecutor command) {
        Task.Factory.StartNew(() => command.Run());
        // Thread thread = new Thread(() => {
        //     command.Run();
        // });
        //
        // thread.Start();
    }
}
}