public async void InitService() { IEnumerable <Email> emails; while (true) { InitRepo(); emails = repo.All(ConfigHelper.GetMaxAttempts()); await Process(emails); cts.Token.ThrowIfCancellationRequested(); Thread.Sleep(ConfigHelper.GetThreadFrequencyInMinutes() * 60 * 1000); } }