public void Start()
        {
            if (IsRunning)
            {
                return;
            }

            //var looper = ServiceProvider.GetRequiredService<LoopingTyperRunner>();
            //var patternRepeater = new PatternRepeater();
            var patternRepeater = new ComplexPatternRepeater();
            var soundService    = new SoundService();
            var backgroundTask  = new BackgroundTaskRunner(async ct =>
            {
                soundService.Play(SoundServiceSound.Start);
                await patternRepeater.RunAsync(ct);
                soundService.Play(SoundServiceSound.End);
                return(true);
            });

            TaskQueue.Enqueue(backgroundTask);

            if (!IsRunning)
            {
                DoDequeueLoop().GetAwaiter();
            }
        }
 protected override async Task OnCompleted(bool hasCancelled)
 {
     OutputWriter.WriteLine($"Task completed. Was cancelled {hasCancelled}");
     SoundService.Play(SoundServiceSound.End);
     await base.OnCompleted(hasCancelled);
 }
 protected override async Task <bool> OnStarting()
 {
     OutputWriter.WriteLine("Starting task.");
     SoundService.Play(SoundServiceSound.Start);
     return(await base.OnStarting());
 }
 public LoopingTyperRunner(SoundService soundService, OutputWriter outputWriter)
 {
     SoundService = soundService;
     OutputWriter = outputWriter;
 }