Пример #1
0
        void Init(string name, RunnerData runnerData)
        {
            _name       = name;
            _runnerData = runnerData;
#if !NETFX_CORE
            //threadpool doesn't work well with Unity apparently
            //it seems to choke when too meany threads are started
            new Thread(() => runnerData.RunCoroutineFiber())
            {
                IsBackground = true
            }.Start();
#else
            Task.Factory.StartNew(() => runnerData.RunCoroutineFiber(), TaskCreationOptions.LongRunning);
#endif
        }
Пример #2
0
        public MultiThreadRunner(string name, bool relaxed = true, int intervalInMs = 0)
        {
            _name = name;
            var runnerData = new RunnerData(relaxed, intervalInMs, name);

            _runnerData = runnerData;
#if !NETFX_CORE || NET_STANDARD_2_0 || NETSTANDARD2_0
            //threadpool doesn't work well with Unity apparently
            //it seems to choke when too meany threads are started
            var thread = new Thread(() => runnerData.RunCoroutineFiber())
            {
                IsBackground = true
            };

            thread.Start();
#else
            var thread = new Task(() =>
            {
                _name = name;

                RunCoroutineFiber(ref runnerData);
            }, TaskCreationOptions.LongRunning);

            thread.Start();
#endif
        }