المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Long operation in c#, when does main end?



C# Programming
09-17-2009, 02:23 AM
Hi,
my problem is the following: I wrote a program that downloads lots of images from the internet (not porn though :P). Anywhoo, when i had the entire program in one thread it was not very responsive during the downloading (i used application.doevents in between the downloading cycles). When i added a separate thread for the downloading part i could move the windows around on the screen quickly and with no problems. What i don't quite understand is the why.

What controls the movement of the program window during execution? Does the main thread decide how much processor time it gives for the program and how much for the movement? When does the main thread end? Does it ever end, due to the fact that it has to handle button clicks?

Does main thread end when there are multiple threads? If it does end before the downloading thread, how can the smooth window movement during downloading be explained (as there is still only one thread running?).

TY