I have a main form with a ListView control that contains a list of remote machines within my domain (Active Directory). By right-clicking on any item, a second form with WMI Objects' details of that machine opens. Retrieving those data takes some time, so I wanted a third form to open, just showing a "please wait"-kinda message. This is the code within my main form:
private async void cmShowDetails_Click(object sender, EventArgs e)
{
nomeComputer = lvElencoMacchine.SelectedItems[0].Text;
HamsterWheel hw = new HamsterWheel(); // create an instance of the waiting form
await Task.Run(()=> {
WorkstationDetails wdForm = new WorkstationDetails(nomeComputer, FUNZIONEFORM.VISUALIZZAZIONE);
hw.Close();
if (!wdForm.IsDisposed) wdForm.ShowDialog();
});
hw.ShowDialog();
}
I see that once calling the construction method of the form in which I have to show the machine details, the focus remains on that thread. What am I missing?ù
Thanks. Davide.