internal static void Start(string[] args, bool contentStart = false)
        {
            if (_hasStarted)
            {
                throw new InvalidOperationException("Cannot start twice!");
            }

            _hasStarted = true;

            if (!CommandLineArgs.TryParse(args, out var parsed))
            {
                return;
            }

            ThreadPool.SetMinThreads(Environment.ProcessorCount * 2, Environment.ProcessorCount);

            // this sets up TaskScheduler.Current for new tasks to be scheduled off the main thread
            // the LongRunning option causes it to not be scheduled on the thread pool, so it's just a plain thread with a task context
            new TaskFactory(
                CancellationToken.None,
                TaskCreationOptions.LongRunning,
                TaskContinuationOptions.None,
                RobustTaskScheduler.Instance
                ).StartNew(() => ParsedMain(parsed, contentStart))
            .GetAwaiter().GetResult();
        }
Beispiel #2
0
 internal static void Main(string[] args)
 {
     if (CommandLineArgs.TryParse(args, out var parsed))
     {
         ParsedMain(parsed);
     }
 }
Beispiel #3
0
        internal static void Start(string[] args, bool contentStart = false)
        {
            if (_hasStarted)
            {
                throw new InvalidOperationException("Cannot start twice!");
            }

            _hasStarted = true;

            if (CommandLineArgs.TryParse(args, out var parsed))
            {
                ParsedMain(parsed, contentStart);
            }
        }
Beispiel #4
0
        internal static void Start(string[] args, ServerOptions options, bool contentStart = false)
        {
            if (_hasStarted)
            {
                throw new InvalidOperationException("Cannot start twice!");
            }

            _hasStarted = true;

            if (!CommandLineArgs.TryParse(args, out var parsed))
            {
                return;
            }

            ThreadPool.SetMinThreads(Environment.ProcessorCount * 2, Environment.ProcessorCount);

            ParsedMain(parsed, contentStart, options);
        }