public void Execute(CancellationToken token) { // Check if this has already been processed if (book.Metadata.ContainsKey("GoodreadsWorkId")) { return; } log.Report($"Processing {book.Title}"); var id = book.Metadata["GoodreadsBookId"]; var goodreads_book = client.GetBookById(id, token); Task.Factory.StartNew(() => UpdateBook(book, goodreads_book), token, TaskCreationOptions.DenyChildAttach, scheduler) .Wait(token); }
public void Execute(CancellationToken token) { Thread.Sleep(1000); var book = collection.Books.FirstOrDefault(b => b.Metadata["GoodreadsWorkId"] == entry.Metadata["GoodreadsWorkId"]); var found_in_collection = true; if (book == null) { var goodreads_book = client.GetBookById(entry.Metadata["GoodreadsBestBookId"], token); book = GoodreadsMapper.Map(goodreads_book); found_in_collection = false; } log.Report($"Processing {book.Title}"); Task.Factory.StartNew(() => Update(book, found_in_collection), token, TaskCreationOptions.DenyChildAttach, scheduler) .Wait(token); }