Add semaphore for accessing send stream

This commit is contained in:
Christian Kratky
2017-09-28 09:29:47 +02:00
parent e947881aca
commit d09455f78e
2 changed files with 32 additions and 30 deletions
@@ -113,16 +113,16 @@ namespace MQTTnet.TestApp.NetFramework
.Select(i => CreateMessage())
.ToList();
////if (false)
////{
//// //send concurrent (test for raceconditions)
//// var sendTasks = msgs
//// .Select(msg => PublishSingleMessage(client, msg, ref msgCount))
//// .ToList();
if (true)
{
//send concurrent (test for raceconditions)
var sendTasks = msgs
.Select(msg => PublishSingleMessage(client, msg, ref msgCount))
.ToList();
//// await Task.WhenAll(sendTasks);
////}
////else
await Task.WhenAll(sendTasks);
}
else
{
await client.PublishAsync(msgs);
msgCount += msgs.Count;
@@ -134,7 +134,7 @@ namespace MQTTnet.TestApp.NetFramework
var now = DateTime.Now;
if (last < now - TimeSpan.FromSeconds(1))
{
Console.WriteLine($"sending {msgCount} inteded {msgChunkSize / interval.TotalSeconds}");
Console.WriteLine($"sending {msgCount} intended {msgChunkSize / interval.TotalSeconds}");
msgCount = 0;
last = now;
}