public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { VMItem vm = (items.First() as VMItem); string SnapshotName; if (modItems.Any()) { SnapshotName = (modItems.First() as ITextItem).Text; } else { SnapshotName = AddinManager.CurrentLocalizer.GetString("Snapshot (") + DateTime.Now + ")"; } VMThread thread = new VMThread("VBoxManage", "snapshot " + vm.Uuid + " take '" + SnapshotName + "'", vm.Status, ref vm); Thread t = new Thread(new ThreadStart(thread.DoAction)); t.IsBackground = true; t.Start(); yield break; }
public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { foreach (Item i in items) { VMItem vm = (i as VMItem); VMThread thread; Thread t; if (modItems.Any()) { thread = new VMThread(ref vm); t = new Thread(new ThreadStart(thread.DoShutdownRestoreAction)); } else { thread = new VMThread(VMState.off, ref vm); t = new Thread(new ThreadStart(thread.DoAction)); } t.IsBackground = true; t.Start(); } yield break; }
//empty constructor, only for complex actions public VMThread(ref VMItem v) { this.vm = v; }