How do I keep a responsive UI while processing large amounts of data?

前端 未结 3 1021
野性不改
野性不改 2020-12-06 13:24

I am creating winform to process (convert txt files to tiff) large amount of files. I put all the code behind a button (btnProcess). Is this a good idea? It works but I noti

3条回答
  •  伪装坚强ぢ
    2020-12-06 14:08

    BackgroundWorker class

    The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

    The page I linked above contains a complete BackgroundWorker example.

提交回复
热议问题