Some simple questions

Hi all,

I come from the ASP.Net world. I'm writing my first winforms app and have a few questions. Basically, the app is a conversion utility that will recurse through directories and combine single TIFF files into multi-page TIFF files.

I am using the progress bar along with a label to tell the user where they're at in the conversion: (Converting file 500 of 10005). I want the labels to update with each pass of my FOR...NEXT loop. Do you use the .Update() method of the labels If so, why does the form freeze when my routine is running and I try to move the window within my desktop

Also, how do I make my FOR...NEXT loop asynchronous so the user can cancel it at anytime


Answer this question

Some simple questions

  • Mark Peterson

    To update the labels, just set the Text property to a new value.

    The reason your form freezes is that all the conversion takes place in the same thread as the UI. The one thread is so busy converting your images that it doesn't get around to update the window.

    The solution for this problem as well as the cancelling is to create a new thread. If you're using VS2005, the easiest way is the BackgroundWorker component. It creates the new thread for you, reports progress and can return a result when it's done. (There's also an implementation for .NET 1.x available)

    More info and download of 1.x version: http://www.danielmoth.com/Blog/2004/12/backgroundworker-sample.html



  • KatherineG

    Dakofella, I need to do the same that your app is doing - take some tiff files and combine them to one. Would you mind sending or posting the code my email is agm@dk.ibm.com.

    thank you.


  • Some simple questions