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

مشاهدة النسخة كاملة : Help with BackgroundWoker



C# Programming
11-17-2009, 12:50 PM
Hi

I've got a web service running on a BackgroundWorker which updates the weather in a specified time limit. I've also got a combobox listing a whole bunch of cities. Now the thing is, in the Do_work event of the backgroundworker I update the weather and let the thread sleep for a couple of minutes, and if the user selects a new city, the user has to wait the specified amount of time before it updates. How can I get the weather to update say every 10 minutes, but as soon as a new city is selected, don't wait 10 minutes, and instead update the weather as soon as a new city is selected.
Is there a way to restart the BackgroundWorker perhaps?