timer, threading and appDomain ... complicated question

F

Frank Uray

Hi all

I have some trouble with threading and AppDomain ... :-((

Within a MDI Container Form,
I am loading a assembly into a AppDomain like this:
"System.AppDomain local_AppDomainPlugIn =
System.AppDomain.CreateDomain("SomeName");"

and calling Method remote Load like this:
"local_AppDomainPlugIn.DoCallBack(new
System.CrossAppDomainDelegate(local_InterfaceObject.remote_Load));"

The method remote_Load is showing a new form within the MDI Container Form.
When I call this (in MDI Container Load), it works fine.


Now I have new a timer which should do this calling,
but of corse the timer runs in another thread then MDI Container Form.
When I now call it, the new form loads but it is frozen ... :-(((

I am a little lost now because I do not know what is
the best way to do it ??
I know it would work like this:
"this.Invoke(new delegateLoad(local_InterfaceObject.remote_Load));"
but I need to have it in its own AppDomain.

Thank you much for any comments !!

Best regards
Frank Uray
 
C

Ciaran O''Donnell

This definately sounds like a problem with the fact there is no message pump
on thread that makes the form. Test this by using a
System.Windows.Forms.Timer so the form is made on the main UI thread. It this
fixes the problem but you want the form to be made in a background thread to
keep responsiveness in the Main form while it does, call Application.Run on
the new form to setup a message pump for it.

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


Peter Duniho said:
[...]
Now I have new a timer which should do this calling,
but of corse the timer runs in another thread then MDI Container Form.
When I now call it, the new form loads but it is frozen ... :-(((

Without a concise-but-complete code sample, it's impossible to know for
sure. However, I suspect that the issue has nothing to do with the
AppDomain. Rather, it's probably just because you have no message pump in
the thread that created the form.

You can solve that either by showing the form with the Application.Run()
method, or by making sure that the code that actually creates the form is
executed on the thread that already has a message pump (i.e. your main GUI
thread, assuming you have one).

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top