Home > Net >  Embed form how to hang without blocking the main form of the UI thread
Embed form how to hang without blocking the main form of the UI thread

Time:11-19

To achieve such effect:
Forms A is the main form, the form B is always displayed in the above, A when form B busy hang, can also be A response to A user action

Tried the solution:
1, SetParent, make the form B embedded form A as A child window, form B (Sleep) when hung, A loss of response
2, the SetWindowLong (hwnd_b GWL_HWNDPARENT, hwnd_a), that is always on A, B effect like SetParent, B hang will affect A

Don't want to use the solution:
1, set the B as the TopMost and presented in a new thread, this will affect other Windows desktop experience
2, Google browser tabs studied, find it difficult to realize the background and rendering process isolation
3, ShowDialog, this will make A cannot gain

Is there any way to achieve both B has always been on A run to their respective each other again? Just like browser tabs

CodePudding user response:

This is... Not b affected but the UI thread only one

CodePudding user response:

B why busy hang? If B hangs, the launch of the UI thread blocked.
Need to solve the problem of B hangs from the source.

CodePudding user response:

1, open a separate thread running B
2, open a thread running in B may hang code

CodePudding user response:

What is called "hang"? Don't put the main thread of death is called a hang? So "hang again but don't hang" isn't it contradictory? You have thrown hang first.

CodePudding user response:

You have a problem thinking,
1, A and B are sharing A UI thread,
2, there is no other pending operations, the UI will not hang card dead,
3, hang card dead because the UI for other reasons, you should use multithreading to solve this problem, rather than solve the problem of what the UI jammed,
  •  Tags:  
  • C#
  • Related