2018-12-19 20:50:56 +01:00
|
|
|
|
using System.Threading.Tasks;
|
2016-12-05 08:00:09 +01:00
|
|
|
|
|
|
|
|
|
namespace Test
|
|
|
|
|
{
|
|
|
|
|
public class MarcoEmitter
|
|
|
|
|
{
|
2018-12-19 20:50:56 +01:00
|
|
|
|
//private readonly IPublisher publisher;
|
2016-12-05 08:00:09 +01:00
|
|
|
|
|
|
|
|
|
|
2018-12-19 20:50:56 +01:00
|
|
|
|
/*public MarcoEmitter(IPublisher publisher)
|
2016-12-05 08:00:09 +01:00
|
|
|
|
{
|
|
|
|
|
this.publisher = publisher;
|
|
|
|
|
}
|
2018-12-19 20:50:56 +01:00
|
|
|
|
*/
|
2016-12-05 08:00:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task Run()
|
|
|
|
|
{
|
2017-10-17 10:34:07 +02:00
|
|
|
|
//await publisher.Publish(new MarcoMessage());
|
2017-02-05 23:22:34 +01:00
|
|
|
|
|
2017-02-12 19:04:26 +01:00
|
|
|
|
/*
|
2016-12-05 08:00:09 +01:00
|
|
|
|
var concurrent = new SemaphoreSlim(20);
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2017-02-05 23:22:34 +01:00
|
|
|
|
for (var x = 0; x < 200; x++)
|
2016-12-05 08:00:09 +01:00
|
|
|
|
{
|
2017-02-05 23:22:34 +01:00
|
|
|
|
await concurrent.WaitAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await publisher.Publish(new MarcoMessage());
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
concurrent.Release();
|
|
|
|
|
}
|
2016-12-05 08:00:09 +01:00
|
|
|
|
}
|
2017-02-05 23:22:34 +01:00
|
|
|
|
|
2017-02-08 15:52:24 +01:00
|
|
|
|
await Task.Delay(200);
|
2017-02-05 23:22:34 +01:00
|
|
|
|
}
|
2017-02-12 19:04:26 +01:00
|
|
|
|
*/
|
2017-02-05 23:22:34 +01:00
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(1000);
|
2017-02-12 19:04:26 +01:00
|
|
|
|
}
|
2018-12-19 20:50:56 +01:00
|
|
|
|
// ReSharper disable once FunctionNeverReturns
|
2016-12-05 08:00:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|