void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorkerArgs args = (BackgroundWorkerArgs)e.Argument; IMigrationService migrationService = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService)); switch (args.Task) { case BackgroundWorkerTask.Start: migrationService.StartSessionGroup(args.SessionGroupUniqueId); e.Result = args; break; case BackgroundWorkerTask.Resume: migrationService.ResumeSessionGroup(args.SessionGroupUniqueId); break; case BackgroundWorkerTask.Stop: migrationService.StopSessionGroup(args.SessionGroupUniqueId); break; case BackgroundWorkerTask.Pause: migrationService.PauseSessionGroup(args.SessionGroupUniqueId); break; } }