Hi,
I am developing a small program that resizes one or more images at the same time. I want to implement a function that allows users to stop the program when it is processing images by clicking a "Cancel" Button. But I don't know how to do that properly. Can anyone help me
Thanks
Ran

Stop function execution
Harald Köstinger
You can do that by creating a thread that does your image processing. You can then provide a cancel button which just kills the thread that you have started...
cheers,
Paul June A. Domag
raj4work
Al_at_Uni
Hello.
Have a look at BackgroundWorker. Create a loop in it's executing method which checks its "Cancelled" property, and if not set, resizes the image and shows the progress to the user. You should not kill the thread on cancel if you want to complete the operation of resizing the current image before stopping.
Checklist: On BackgroundWorker you should implement all three events and set propertire: WorkerReportsProgress and WorkerSupportsCancellation. You should cancel the thread upon program exit (maybe call the same method as your cancelevent calls )
Do not alter any controls from within your executing (DoWork) method. You have the ProgressChanged event for that.
Happy threading.
hallem
RoninBraenk
Check the source on that for background threading for image resizing. It's VERY old, and needs a lot more work that I just don't care to spend on it. However, it does effectively start/stop, and all that with a behind the scenes thread.
Paul Siermann
Thank you very much.
Ran