Creating and returning a form from a thread - C# 2.0

  • Thread starter Thread starter nadeem_far
  • Start date Start date
N

nadeem_far

Hello All,

We have two applications in .NET 2.0 C#.

App1 communicates with App2 throught App2's COM layer. App1 has the
ability to load some of the forms exposed by App2.

The problem is when the user tries to load the form from App2 for the
first time the whole GUI freezes up as the UI thread gets busy in
loading all the dlls etc and it sometimes takes up to 2~3 mins. to
load one form. Once all the Dlls are loaded the performace of loading
forms from App2 improves.

I tried to put the form loading calls into a worker thread and am
showing a progress window, this keeps my main thread responsive and
when the form is created I save its reference in a class level
variable to access it from main thread after the worker has stopped.
The problem is when the worker thread is done loading the form and I
call the Thread.Join, the form that I got from App2 also gets killed.

I think it is related to that windows rule that says the control will
only exist in the thread that creates it.

Any ideas how to solve this problem?
 
My first move would be first to check why it takes 2-3 minutes. This is not
something that looks like a normal behavior to me. Adding threading would
hide the problem rather than solving it and then you'll have the added
complexity of running the UI into several threads and AFAIK this is really
not an usual situation...

--
Patrice

<[email protected]> a écrit dans le message de groupe de discussion :
(e-mail address removed)...












- Show quoted text -

Patrice,

The slow loading on first call is due to the fact that App2 connects
to different systems to load the cache data that is needed by the
form.

So we cannot do anything about that.

Nad
 
Back
Top