Modal dialogs, often necessary to exist in some applications, but there are many problems.
Question 1: Processing of blocking messages. This problem is better.
Question 2: Even in a single-threaded program, it will also cause asynchronous execution of the program. I have encountered this similar problem. The control module calls a function similar to the deleteInstance destroyed a module, but due to the existence of the on-the-state dialog, the result, there is a problem. The details are as follows, where the dialog box appears, it is a network callback processing function. Although the dialog is destroyed when calling DeleteInstance, but since the call deleinstance is too fast, it has caused the network after this process. The message callback function continues to handle, but the class that processes has not existed. The result is CRASH. In response to this problem, negotiation can be performed between the control module and the control module, or you can call Sleep and take a break before calling DeleteInstance. This way, all problems can be handled.