Threading question

V

Vadym Stetsyak

Hello!

I've got a class, representing Windows Form (Form1);
When I launch new thread user interface e.g. Form1 stops responding until
the worker thread is completed.

So the question - how this can be avoided. Roughly speaking I need to
perform some job after the button click and while this job is completing
user GUI can respond.

Here is the code I'm using:
ThreadStart threadStart = new ThreadStart(DoSomething);

Thread thread = new Thread (threadStart);
thread.Start();

In the debuger thread.Start() returns immediately. But GUI freezes until the
work thread is completed.
--
Vadym Stetsyak
ICQ 161730125

He, who commands the past - commands the future
He, who commands the present - commands the past
 
J

Joerg Jooss

"Vadym Stetsyak" spoke:
Hello!

I've got a class, representing Windows Form (Form1);
When I launch new thread user interface e.g. Form1 stops responding
until the worker thread is completed.

So the question - how this can be avoided. Roughly speaking I need to
perform some job after the button click and while this job is
completing user GUI can respond.

Here is the code I'm using:
ThreadStart threadStart = new ThreadStart(DoSomething);

Thread thread = new Thread (threadStart);
thread.Start();

In the debuger thread.Start() returns immediately. But GUI freezes
until the work thread is completed.

Does "DoSomething" try to access UI components? That is *not* allowed.
For a general introduction into the whole topic, check out
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/default.as
px

Cheers,
 
V

Vadym Stetsyak

Actually yes. I am quite a newbie to Windows Forms and C#.
Thanks for the answer.
 

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

Similar Threads


Top