Hello,
I need to write an app that that will iterate over our database, and perform various anaylsis on each record. In order to do this (partially for the learning exercise in creating plugin support) I want to use a Plugin model.
Currently, I have a simple Interface in my main app, which plugins can Implement. My app then loads all DLL's in a folder looking for ones implementing the Interface.
As you can see in the pseudo-code below, I have to keep performing a loop through all loaded plugins calling the process methods.
Sub ProcessData()
For Each Record In MyDataSet
For Each Plugin In MyPluginCollection
Plugin.ProcessRecord(Record)
Next
Next
End Sub
If I wanted each of the plugins to fire asynchronously, how would I track when all the plugins are done?
Sub ProcessData()
For Each Record In MyDataSet
# Start all the plugins off on their processing task
For Each Plugin In MyPluginCollection
CreateNewThreadFor Plugin.StartProcess(Record)
Next
# Do not start the next record until this record is completed by all plugins
Dim Complete As Boolean = False
While Not Complete
For Each Plugin In MyPluginCollection
If Plugin.IsBusy Then
Complete = False
End If
Next
DoEvents
End While
Next
End Sub
Or am I just opening myself up for a world of pain trying to multithread it in this way?