As long as you insist on using a modal message box in the dragdrop method then the originating application will freeze until you dismiss the message box and return from the method.
See my earlier comment about using a timer.
For example,
public partial class Form1 : Form
{
string[] FilesToGet;
bool ready = true;
public Form1()
{
InitializeComponent();
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if ((e.Data == null) || !e.Data.GetDataPresent(DataFormats.FileDrop))return;
FilesToGet = (string[])e.Data.GetData(DataFormats.FileDrop);
ready = false;
timer1.Start();
//if (!PreliminaryValidation()) { return; }
//StartProcessing(FilesToGet);
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (ready && ((e.Data == null) || e.Data.GetDataPresent(DataFormats.FileDrop)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private bool PreliminaryValidation()
{
// Replace this with the actual validation code
DialogResult result = MessageBox.Show(
"You have not read the manual! Would you like to proceed at your own risk?",
"Saftey alert",
MessageBoxButtons.YesNo
);
return (result == DialogResult.Yes);
}
private void StartProcessing()
{
this.SuspendLayout();
listView1.Items.Clear();
foreach (var item in FilesToGet)
{
_ = listView1.Items.Add(item);
}
this.ResumeLayout(false);
// Processing code goes here.
//throw new NotImplementedException();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
if (!ready)
{
if(PreliminaryValidation())
{
StartProcessing();
}
ready = true;
}
}
}