protected override void OnStart(string[] args) { if (args.Length == 1) { Settings.Default.settings = args[0].Substring(1); Settings.Default.Save(); MessageBox.Show("The config path has been set.", "BCRPDB Server", MessageBoxButtons.OK, MessageBoxIcon.Information); Environment.Exit(0); } if (string.IsNullOrWhiteSpace(Settings.Default.settings)) { MessageBox.Show("The config path is invalid. View the readme and make sure your save paths are correct.", "BCRPDB Server", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } cfg = new Config(Settings.Default.settings); log = new Log(cfg.Log, cfg.Aliases); list = new TcpListener(IPAddress.Parse(cfg.IP), cfg.Port); Civilians = new List <Civ>(); if (File.Exists(cfg.Database)) { foreach (string line in File.ReadLines(cfg.Database)) { Civilians.Add(Civ.Parse(line, File.GetLastWriteTime(cfg.Database))); } } try { list.Start(); } catch { MessageBox.Show("The specified port (" + cfg.Port + ") is already in use.", "BCRPDB Server", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } Log.WriteLine("Listening for connections..."); ThreadPool.QueueUserWorkItem(x => { while (true) { ThreadPool.QueueUserWorkItem(Connect, list.AcceptSocket()); } }); }