public DataLoaderProvider(DisclaimerDataLoader disclaimerDataLoader, EventPagesDataLoader eventPagesDataLoader, LanguagesDataLoader languagesDataLoader, LocationsDataLoader locationsDataLoader, PagesDataLoader pagesDataLoader) { DisclaimerDataLoader = disclaimerDataLoader; EventPagesDataLoader = eventPagesDataLoader; LanguagesDataLoader = languagesDataLoader; LocationsDataLoader = locationsDataLoader; PagesDataLoader = pagesDataLoader; }
/// <summary> /// Starts the background downloading. /// </summary> public static void Start(Action refreshCommand, PagesDataLoader pagesdataLoader) { if (IsRunning) { throw new Exception("BackgroundDownloader is already running."); } _pagesdataLoader = pagesdataLoader; _workerTask = Task.Run(() => { try { Worker(_cancellationTokenSource.Token, refreshCommand); } catch (Exception e) { Debug.WriteLine(e); // ignored (will only appear, when cancellation was requested) } _cancellationTokenSource.Token.ThrowIfCancellationRequested(); }, _cancellationTokenSource.Token); // Pass same token to StartNew. }