I want to create a simple application, just one form with a Pause button.
On startup the application will search a list of paths for any files and do some stuff.
My problem is that the the form become unresponsive (Not Responding) and therefore I can't get the Pause button click event to trigger.
Any help would be appriciated.
Posted Jul 6, 2008, 6:33 PM
You can set your query code to run on a separate thread, separate from the user interface and then if you need the thread to pause, you can suspend it (though its not really recommended, I havent found a good reason for it though. Probably due to deadlock issues and stuff.).
Do a little research on multithreading, it sounds intimidating, but the .NET framework makes this sort of thing much easier than its been in the past.
From our very own Mike Gold:
http://www.c-sharpcorner.com/UploadFile/mgold/MultithreadingIntro10062005000439AM/MultithreadingIntro.aspx?ArticleID=920ecafc-e83b-4a9c-a64d-0b39ad885705
And another one:
http://www.programmersheaven.com/articles/arun/multithread.htm
Just remember that if you need to access any controls on the user interface from another thread, you will need to use a delegate otherwise you will end up with CrossThreadException's