I have a simple BackgroundWorker
that should generate results, but I don't know how to get them back to my calling method.
I have read a number of answers, and they all show me how the RunWorkerCompleted
event can receive the results of the DoWork
event handler, and to prove this they show a message box with the result. That's all good, but how do I get a result back to the actual method that called RunWorkerAsync
?
myResult=myBackGroundWorker.RunWorkerAsync(); // This obviously doesn't compile
This answer in particular has been very useful:
How to make BackgroundWorker return an object
but I still don't know how to access the results. This answer also mentions the use of a delegate:
BackgroundWorker Return A Value?
but I don't understand if this would solve my problem, or if I would still just get the result inside the RunWorkCompleted event handler.