private async Task RunAsync(CancellationToken cancellationToken) { var repo = new ConfigurationRepository(); var target = RoleEnvironment.GetConfigurationSettingValue("Stormancer.Target").Split('/'); var peersManager = new PeerManager("http://api.stormancer.com",target[0], target[1], target[2]); var _ = Task.Run(() => WriteLogs()); peersManager.RunPeers(200, cancellationToken); while (!cancellationToken.IsCancellationRequested) { try { var peersCount = await repo.GetTargetInstancesCount(); await peersManager.SetInstanceCount(peersCount); } catch (Exception ex) { Trace.TraceError(ex.ToString()); } await Task.Delay(1000); } }
static void Main(string[] args) { try { //ThreadPool.SetMaxThreads(workerThreads: 400, completionPortThreads: 400); //ThreadPool.SetMinThreads(workerThreads: 200, completionPortThreads: 200); var nbBoids = int.Parse(args[0]); var pM = new PeerManager(ConfigurationManager.AppSettings["api"]??"http://api.stormancer.com",ConfigurationManager.AppSettings["accountId"], ConfigurationManager.AppSettings["applicationName"], ConfigurationManager.AppSettings["sceneName"]); WriteLogs(); var cts = new CancellationTokenSource(); pM.SetInstanceCount(nbBoids); pM.RunPeers(200, cts.Token); Console.Read(); cts.Cancel(); } catch (Exception ex) { } }