Код: Выделить всё
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmFilter());
}
[STAThread]
static void Main(string[] args)
{
var thread = new Thread(() =>
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmFilter());
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
var frm = new frmFilter(); // this form showing
frm.ShowDialog();
}
< /code>
Мне нужно объяснение, почему этот код показывает форму, если я запускаю свой EXE из другого приложения? Если я удалю хотя бы одну строку, все перестанет работать. < /P>
объясните, почему работает этот код? Будет отображаться форма FRMFilter: < /p>
static void Main(string[] args)
{
var thread = new Thread(new ThreadStart(() =>
{
MessageBox.Show("test"); // If I delete this line, the form will not be displayed, why?
var frm = new frmFilter();
frm.ShowDialog();
}));
thread.Start();
}
< /code>
Это код приложения C ++, который запускает мой Exe, в которой форма должна быть поверх приложения C ++ < /p>
CString sPath = GetFilePath( m_sInsFolder );
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = m_sParserApp;
ShExecInfo.lpParameters = sArg;
ShExecInfo.lpDirectory = sPath;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
int ret = (int)ShellExecuteEx(&ShExecInfo);
< /code>
Я не могу изменить код c ++ < /p>
Введите описание изображения здесь < /p>
my c# код выше работает работает Но я не знаю почему. Я хочу хорошее решение, чтобы иметь форму C# в верхней части приложения C ++. C# net 4.6.1, c ++ - приложение MFC.
Подробнее здесь: https://stackoverflow.com/questions/793 ... pplication
Мобильная версия