Aaronontheweb on dev
[PORT] Akka/Akka#24722: Bugfix … (compare)
Aaronontheweb on dev
Add `IThreadPoolWorkItem` suppo… (compare)
public class JobExecutor : ReceiveActor
{
private readonly Application _application;
private bool _working = false;
public JobExecutor(Application application)
{
_application = application;
Receive<BeginWork>(AsyncBehavior.Reentrant, _ => _application.ExecuteInScope(() => OnBeginWork()));
}
private async Task OnBeginWork()
{
if (_working)
{
Console.WriteLine("Executando trabalho ainda {0}", Thread.CurrentThread.ManagedThreadId);
return;
}
_working = true;
Console.WriteLine("Iniciando trabalho {0}", Thread.CurrentThread.ManagedThreadId);
//Thread.Sleep(8000);
await Task.Delay(10000);
Console.WriteLine("Finalizando trabalho {0}", Thread.CurrentThread.ManagedThreadId);
_working = false;
}
}