Hi All,
I'm a little new to .NET and I'm having a threading issue I'm
having a problem resolving/understanding.
I'm making a plug-in into Word. A menu-option ('Check Updates')
spawns a new thread which gathers information, and then displays a
form (modal, 'ShowDialog'). Once the form is Close() 'd, it tries to
run a system process - opens a website using:
openWebsite(url)
{
Process ^ newProcess = gcnew Process();
newProcess->StartInfo->FileName = url;
newProcess->StartInfo->CreateNoWindow = true;
newProcess->StartInfo->WindowStyle = ProcessWindowStyle::Normal;
newProcess->StartInfo->UseShellExecute = true;
newProcess->StartInfo->ErrorDialog = false;
newProcess->Start();
}
The thread spawned from the menu-option click is something as follows:
ThreadStart()
{
gather information;
MyForm ^ form = gcnew MyForm;
form->ShowDialog();
if(form->yes) openWebsite("http://whatever/");
}
The problem I'm having is that newProcess->Start() method freezes
for about 30 seconds before doing anything. What's interesting is
that I can open a website without a problem before running the
dialog, but not after:
ThreadStart()
{
gather information;
openWebsite("http://whatever/"); // works fine
MyForm ^ form = gcnew MyForm;
form->ShowDialog();
if(form->yes) openWebsite("http://whatever/"); // freezes 30
seconds
}
I thought maybe some events need to be processed, so I stuck a
'Application::DoEvents();' after the ShowDialog, but it did nothing.
Can anyone help?
Sincerely,
Andrew