2016-12-05 07:00:09 +00: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 18:04:26 +00:00
|
|
|
|
await publisher.Publish(new MarcoMessage());
|
2017-02-05 22:22:34 +00:00
|
|
|
|
|
2017-02-12 18:04:26 +00:00
|
|
|
|
/*
|
2016-12-05 07:00:09 +00:00
|
|
|
|
var concurrent = new SemaphoreSlim(20);
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2017-02-05 22:22:34 +00:00
|
|
|
|
for (var x = 0; x < 200; x++)
|
2016-12-05 07:00:09 +00:00
|
|
|
|
{
|
2017-02-05 22:22:34 +00:00
|
|
|
|
await concurrent.WaitAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await publisher.Publish(new MarcoMessage());
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
concurrent.Release();
|
|
|
|
|
}
|
2016-12-05 07:00:09 +00:00
|
|
|
|
}
|
2017-02-05 22:22:34 +00:00
|
|
|
|
|
2017-02-08 14:52:24 +00:00
|
|
|
|
await Task.Delay(200);
|
2017-02-05 22:22:34 +00:00
|
|
|
|
}
|
2017-02-12 18:04:26 +00:00
|
|
|
|
*/
|
2017-02-05 22:22:34 +00:00
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(1000);
|
2017-02-12 18:04:26 +00:00
|
|
|
|
}
|
2016-12-05 07:00:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|