private object LaunchImageEditorThread(object parameter)
{
string fileName = (string)parameter;
Process imageEditor = new Process();
string paintProgramPath = Factory.AGSEditor.Preferences.PaintProgramPath;
if (string.IsNullOrEmpty(paintProgramPath))
{
imageEditor.StartInfo.FileName = GetAssociatedProgramForFileExtension(System.IO.Path.GetExtension(fileName));
imageEditor.StartInfo.Arguments = string.Format("\"{0}\"", fileName);
}
else
{
imageEditor.StartInfo.FileName = paintProgramPath;
imageEditor.StartInfo.Arguments = string.Format("\"{0}\"", fileName);
}
imageEditor.Start();
try
{
imageEditor.WaitForInputIdle(15000);
}
catch (InvalidOperationException)
{
// if it's a console app, WaitForInputIdle doesn't work
}
imageEditor.WaitForExit();
imageEditor.Dispose();
return null;
}