public async Task CopyFileAsync(string origin, string destination) { await retryingThreadLoop.StartAsync( CreateRetryingFileJob( async() => File.Copy(origin, destination, true))); while (!File.Exists(destination)) { await threadDelay.ExecuteAsync(100); } }
public async Task <string> PrepareTemporaryFolderAsync(string relativePath) { var finalPath = GetFullPathFromTemporaryPath(relativePath); WatchDirectory(finalPath); await threadDelay.ExecuteAsync(1000); return(finalPath); }
async void UserInterfaceViewModel_UserInterfaceDataControlAdded(object sender, UserInterfaceDataControlAddedEventArgument e) { ActiveScreen = screenManager.GetActiveScreen(); Source = e.Package.Data.Source; Count = mainViewModel .UserInterfaceViewModel .Elements.Count(x => x.Data.Source.Text == Source.Text); ClipboardQuantityShown?.Invoke(this, new DataSourceClipboardQuantityShownEventArgument()); await threadDelay.ExecuteAsync(environmentInformation.GetIsDebugging()? 3000 : 1500); ClipboardQuantityHidden?.Invoke(this, new DataSourceClipboardQuantityHiddenEventArgument()); }
async Task WaitForCombinationRelease() { var decisecondsPassed = 0; while (!IsCancellationRequested && IsOneCombinationKeyDown) { await threadDelay.ExecuteAsync(100); decisecondsPassed++; logger.Information($"Paste combination held down for {decisecondsPassed}."); RaiseDurationPassedEventIfNeeded(decisecondsPassed); } }
async Task WaitForCombinationReleaseOrDurationPass() { var decisecondsPassed = 0; while ( !IsCancellationRequested && keyboardPasteState.IsCombinationFullyHeldDown && !shouldCancel) { await threadDelay.ExecuteAsync(100); decisecondsPassed++; logger.Information($"Paste combination held down for {decisecondsPassed}."); RaiseDurationPassedEventIfNeeded(decisecondsPassed); } }
public async Task DeferAsync( int milliseconds, Action action) { currentDefer = DateTime.UtcNow.Add(TimeSpan.FromMilliseconds(milliseconds)); this.action = action; if (threadLoop.IsRunning) { return; } await threadLoop.StartAsync(async() => { if (DateTime.UtcNow >= currentDefer) { action(); threadLoop.Stop(); return; } var delta = currentDefer - DateTime.UtcNow; await threadDelay.ExecuteAsync((int)delta.TotalMilliseconds); }); }