Dispose of Worker Thread?

J

joey.powell

I have a windows forms app (VS 2005) that uses a worker thread to do
lots of stuff in a job. When I run the job again - always after the
first completes - from the app (back to the UI thread to spawn another
worker thread) I notice that the performance has slowed a lot. Is there
something I need to do to properly dispose of the first worker thread,
or is that management already built in?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

No really, when the method that spawned the thread finish the thread is
done.
Are you keeping a reference to the thread in the main UI?
does the thread send back or interact in any way with the UI?
what part of the method itself is slower? maybe it has nothing to do with it
running in a thread, what if you execute it directly in the UI, do you see
the same results when you run it the second time?
 
J

joey.powell

The thread is doing lots of copies via System.IO.File.Copy. It also
interacts a lot with the UI thread via delegates and Invoke calls.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Well execute it in the UI thread and see what happens, you can leave all the
Invoke methods in place.
 

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