You can notify the main thread of progress using the callback method. I.e:
You can pass this callback method to the workflow when it is called (that is, as a delegate), or the workflow code may "know" about it implicitly. In any case, it works.
The jobNumber and status parameters are just examples. You might want you to use a different way of defining tasks to be performed, and you can use the listed type for status. However, you do this, remember that ProgressCallback will be called by several threads at the same time, so if you update any general data structures or write registration information, you will have to protect these resources with locks or other synchronization methods.
You can also use events to do this, but keeping the subscription to the main thread up to date can be a potential problem. You also have the potential of a memory leak if you forget to unsubscribe from the main thread from certain workflow events. Although events will certainly work, I would recommend a callback for this application.
Jim mischel
source share