private async void StartBackupLoop() { var offset = 0L; while (true) { await Task.Delay(30000); _gameboy.SaveState(); await Task.Delay(30000); offset++; if (offset % 60 == 0) { var backupPath = Path.Combine(_gameboy.DataDirectory, "Backup " + DateTime.UtcNow.Ticks); Directory.CreateDirectory(backupPath); _gameboy.PerformBackup(backupPath); } } }
private async void StartRandomizeLoop() { var offset = 0; while (true) { await Task.Delay(100); offset++; if (offset % 5 == 0) { //press the button if we've waited on this field for a half second await _fields[currentColumn, currentRow].Push(); } if (offset % 100 == 0) { _engine.SaveState(); } //reset offset once in a while. if (offset == 100) { offset = 0; } //now fill up the progress bar a little bit. var delta = Math.Min(1, ProgressBar.Maximum - ProgressBar.Value); ProgressBar.Value += delta; if (ProgressBar.Value >= ProgressBar.Maximum) { ProgressBar.Value = 0; RandomizeFields(); } } }