2016-12-05 08:00:09 +01:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Tapeti;
|
|
|
|
|
|
|
|
|
|
namespace Test
|
|
|
|
|
{
|
|
|
|
|
public class MarcoEmitter
|
|
|
|
|
{
|
|
|
|
|
private readonly IPublisher publisher;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MarcoEmitter(IPublisher publisher)
|
|
|
|
|
{
|
|
|
|
|
this.publisher = publisher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task Run()
|
|
|
|
|
{
|
2017-02-12 19:04:26 +01: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
|
|
|
|
}
|
2016-12-05 08:00:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|