Hello,
I want to open a FolderBrowserDiaog when a Batch Task is initialized. The problem, the Dialog does not appear. It appears to be invisibel.
I think I have to set the parent form. How to I get access to it? Or is there a better solution?
Thanks
Hello,
I want to open a FolderBrowserDiaog when a Batch Task is initialized. The problem, the Dialog does not appear. It appears to be invisibel.
I think I have to set the parent form. How to I get access to it? Or is there a better solution?
Thanks
The opendialog() call is in the OnInitializeTask()
Your idea works but if the batch task is part of a sequence the user control will not be shown. I want it to be opened on execution.
Hi Andre,
I see the problem now.
Tasks are run on separate threads and the FolderBrowserDialog is special (a shell dialog), which is why you cannot see the dialog.
See
for more details.
Try adding the following code to the OnIntializeTask method:
DialogResult r = DialogResult.No;
FolderBrowserDialog dialog = new FolderBrowserDialog();
var t = new Thread(() => r = dialog.ShowDialog());
t.IsBackground = true;
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
if (r == DialogResult.OK)
{
var folder = dialog.SelectedPath;
}
Hi Andre,
I see the problem now.
Tasks are run on separate threads and the FolderBrowserDialog is special (a shell dialog), which is why you cannot see the dialog.
See
for more details.
Try adding the following code to the OnIntializeTask method:
DialogResult r = DialogResult.No;
FolderBrowserDialog dialog = new FolderBrowserDialog();
var t = new Thread(() => r = dialog.ShowDialog());
t.IsBackground = true;
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
if (r == DialogResult.OK)
{
var folder = dialog.SelectedPath;
}