public async Task Execute() { Response.ContentType = "text/event-stream"; ExecutionDto execution; do { execution = executionService.GetStage(); if (execution.NeedUpdate) { await HttpContext.Response.WriteAsync($"data:{JsonSerializer.Serialize(execution)}\n\n"); await HttpContext.Response.Body.FlushAsync(); } await Task.Delay(500); }while (!execution.IsFinished); Response.Body.Close(); }