Exemple #1
0
        private async void releaseCmd_Click(object sender, EventArgs e)
        {
            var approveText = "";

            if (CurSel != null)
            {
                approveText = $"Are you sure you want to release the disk image file:\n\r{CurSel.Location}?";
                if (!string.IsNullOrEmpty(CurSel.AttachedTo))
                {
                    approveText += $"\n\r\n\rThis will detach it from the following virtual machines:\n\r{CurSel.AttachedTo}";
                }
            }
            else
            {
                approveText = "Are you sure you want to release the selected disk image files?\n\r\n\rThis will detach them from any virtual machines.";
            }
            if (MessageBox.Show(this, approveText, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            await RunMultiple(async di =>
            {
                if (di?.Location == null)
                {
                    MessageBox.Show(this, "Error getting disk information", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    await RunAsyncAction("Releasing", async(t, p) => await Task.Run(() => { Medium.Release(di.Location); }, t), di.UUID);
                }
            });
        }