private async Task RunAsync(CancellationToken cancellationToken) { ILogger logger = new ApplicationInsightsLogger(); string brokerIp; int numberOfThreads; try { brokerIp = CloudConfigurationManager.GetSetting("BrokerIp"); var threadSet = int.TryParse(CloudConfigurationManager.GetSetting("Threads"), out numberOfThreads); if (!threadSet) { numberOfThreads = DefaultNumberOfThreads; } } catch (Exception exception) { brokerIp = string.Empty; numberOfThreads = DefaultNumberOfThreads; logger.LogException(exception); } while (!cancellationToken.IsCancellationRequested) { try { var broadcastTest = new BroadcastTest(); var broadcastTestTestSetup = new TestSetup(logger, brokerIp, broadcastTest, numberOfThreads); broadcastTestTestSetup.RunTest(int.MaxValue, new TimeSpan(0, 60, 0), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 20), new TimeSpan(0, 0, 20)); } catch (Exception exception) { logger.LogEvent("Incomplete", "Completed test using " + numberOfThreads + " threads"); logger.LogException(exception); } await Task.Delay(new TimeSpan(0, 1, 0), cancellationToken); GC.Collect(); GC.WaitForPendingFinalizers(); GC.WaitForFullGCComplete(); GC.Collect(); } }
static void Main(string[] args) { //Test ntp NtpSyncModule ntpSync = new NtpSyncModule("pool.ntp.org"); ntpSync.GetNetworkTime(); if (ntpSync.SyncedTime.HasValue) { Console.WriteLine("Synced time test: " + ntpSync.SyncedTime.Value); } //HolePunchServerTest holePunchServerTest = new HolePunchServerTest(); //EchoMessagesTest echoMessagesTest = new EchoMessagesTest(); BroadcastTest broadcastTest = new BroadcastTest(); //holePunchServerTest.Run(); //echoMessagesTest.Run(); broadcastTest.Run(); }