public static GuidCollection EnsureUpdatesStaged(IList <Guid> guids, bool sync, out ITaskExecutionInstance inst) { inst = null; GuidCollection nonstagedUpdates = GetNonstagedUpdates(guids); if (nonstagedUpdates.Count <= 0) { return(nonstagedUpdates); } EventLog.ReportVerbose(string.Format("Staging {0} updates...", nonstagedUpdates.Count), "Stage & Distribute"); try { for (int i = 0; i < 5; i++) { inst = Item.GetItem <DownloadSWUPackageTask>(Tasks.Singletons70.DownloadSWUPackage, ItemLoadFlags.WriteableIgnoreAll).CreateInstanceForReplication(nonstagedUpdates, DownloadFilter.Auto, DownloadSWUPackageTask.EReason.DOWNLOAD_STAGE); if (sync) { TaskHelper.WaitForTaskToComplete(inst); } else { return(nonstagedUpdates); } if (inst.InstanceStatus == Altiris.TaskManagement.Common.TaskInstanceStatus.Completed) { return(nonstagedUpdates); } } } catch (Exception exception) { TraceOps.TRACE(exception); } throw new Exception(string.Format("Unable to stage '{0}' updates.", nonstagedUpdates.Count)); }