|
Rank: Newbie Groups: Member
Joined: 1/24/2019 Posts: 3
|
I have Windows Form UI, that shows EO.WinForm.WebControl in the Form in the thread other than main, using async.
This UI is shown in MMC plugin, that unloads AppDomain when MMC is closed.
As the result Eo.Base.Runtime.Shutdown is called during unload, and it is from another thread then EO.WinForm.WebControl was used. It hangs somewhere inside and never finished.
Is there any way to make it stop without hanging?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
You can not do this this way using async which would use an internal thread pool thread that you have no control over with. Because EO.WebControl maintains thread specific resources such as window handles, Windows requires these handles must be destroyed in the same thread in which they were created. So you can not simply use async to create them and then forget about it. You MUST come back to clean up in the same thread at a later time --- we do have some automatic clean up code that can do this for you but only if the original thread is still around and is still actively pumping Windows messages, which obviously would not be the case for a thread pool thread.
To avoid such problem, you will need to avoid using async to create the WebControl control. If you must create the control in a different thread, you can create a separate thread, create the WebControl (along with the containing Form) and then call Application.Run to run that Form. The thread will then terminate when the Form closes.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/24/2019 Posts: 3
|
Thank you.
I ended with something similar - created 1 separate thread and started EO runtime in it. When I need to show my WinForm, I do it in that thread - create form with WebControl, use form.ShowDialog and dispose form after it is closed. The thread still exists and I can reuse it for new dialog.
I call Shutdown in that thread on AppDomain.Unload event. This way it does not hang.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Yes. That works too. The key is you must dispose the form once it is closed in that thread.
|
|