private void scheduleBackgroundworker_DoWork(object sender, DoWorkEventArgs e) { IDependencyResolver container = GlobalConfiguration.Configuration.DependencyResolver; ISchedule ScrapeTaskSchedule = (ISchedule)container.GetService(typeof(ISchedule)); if (ScrapeTaskSchedule != null) { while (!scheduleBackgroundworker.CancellationPending) { ScrapeTaskSchedule.CreateNewTasks(); } } }