Asynchronous Execution in windows forms

后端 未结 2 1133
南方客
南方客 2021-01-03 02:32

I\'m writting a Windows Forms application in C# that executes a lot of long-running procedures on a single button click. This make the GUI to freeze till the execution. Also

2条回答
  •  旧巷少年郎
    2021-01-03 02:57

    The simplest yet efficient way to handle these scenarios, is to use a BackgroundWorker.

    You put your heavy code in the DoWork event handler, and update your GUI through the ProgressChanged event handler.

    You can find a tutorial here
    Or even better they made a "how to" at msdn
    If you have more specific questions after reading it, i'll be happy to oblige.

提交回复
热议问题