public Task StartAsync(CancellationToken cancellationToken) { GeneratePacFile(_setting.HttpProxyPort.ToString()); _ = Task.Run(async() => { var pacAddress = Helper.GetPacAddress(_setting.PacServerPort); _proxySetting.SetPacProxy(pacAddress); string[] prefixes = new string[] { pacAddress }; await new PacServer().SimpleListenerExampleAsync(prefixes); }, cancellationToken); _ = Task.Factory.StartNew(async() => { _httpProxy = new HttpProxy(_setting.HttpProxyPort); while (true) { var client = await _httpProxy.BeginListenAsync(); Channel channel = new Channel(client, new TrojanClientOutProxy(_trojanContext.GetUseTrojan().Pass, _trojanContext.GetUseTrojan().Host, _trojanContext.GetUseTrojan().Port, _trojanContext.GetUseTrojan().ValidServerCert)); channel.StartChannel(); } }, cancellationToken); while (true) { _action.Invoke(); } }