How to use the BackgroundWorker event RunWorkerCompleted

后端 未结 3 1862
说谎
说谎 2021-01-18 05:30

All,I already knew the basic usage the BackgroundWorker to handle multiple thread case in the WinForm . And the code structure looks like below.

In the

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 05:54

    The Result property in RunWorkerCompletedEventArgs is the value you have assigned to the Result property of DoWorkEventHandler in DoWork().

    You can assign anything you like to this, so you could return an integer, a string, an object/composite type, etc.

    If an exception is thrown in DoWork() then you can access the exception in the Error property of RunWorkerCompletedEventArgs. In this situation, accessing the Result property will cause an TargetInvocationException to be thrown.

提交回复
热议问题