public async Task AddFileAsync(string torrentFilePath, bool autoStart, CancellationToken cancellationToken) { try { await client.AddFileAsync(torrentFilePath, autoStart, cancellationToken).ConfigureAwait(false); UpdateStatus(true); } catch (Exception ex) when(!(ex is TaskCanceledException)) { UpdateStatus(false); throw; } }
private async Task AddItemAsync(Torrent item, CancellationToken cancellationToken) { Task addTask; if (item.Location.IsFile) { addTask = torrentClient.AddFileAsync(item.Location.LocalPath, item.AutoStart, cancellationToken); } else { addTask = torrentClient.AddLinkAsync(item.Location.AbsoluteUri, item.AutoStart, cancellationToken); } await addTask.ConfigureAwait(false); }