Здравствуйте, GarryIV, Вы писали:
GIV>Hello, ynblpb!
y>> Забавная ситуация имеется:
GIV>Поставь ReSharper он тебе тонко намекнет, что после return код не выполняется никогда. Соответсвенно наличие\отсутствие там мессаджебокса ни на что не влияет.
GIV>WBR, Igor Evgrafov.
Либо я не корректно поставил вопрос либо пост не внимательно был прочитан.
Я прекрасно знаю что после return не выполняется код.
Непонятно почему если в обработчике есть одна инструкция return приложение
не завершается. И непонятно то почему при непосредственном вызове Application.Exit()
с стоящими после этого вызова инструкциями (в частности MessageBox.Show())
приложение тоже не завершается.
Хотя
Application.Exit Method
This method stops all running message loops on all threads and closes all windows of the application. This method does not force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return. To exit a message loop for the current thread only, call ExitThread.
CAUTION The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.
Иными словами непонятен механизм ни Application.Exit() ни Application.ExitThread()
т.к.
this.Close();
Application.ExitThread();
MessageBox.Show("bla");
такой код тоже не завершает работу приложения.
ЗЫ: MessageBox.Show("bla") в приведенных мной примерах смысловой нагрузки не несет. Нужно лишь
в качестве подопытной инструкции, которая нужна для эксперемента.