Architeture Overview:
Language : C# Windows Form Project using Class Libraries to execute the crawler tasks
I am currently writing a interface (UI) that will be used to “debug” a crawler (or a set of crawlers) i wrote. Each crawler is a .dll
From the interface, i am going to invoke the .dlls and i don’t want to have to wait for them to end their tasks (Crawling, parsing and building the lists of elements internally) to display the results on the interface.
Question:
Is there any way i can, somehow, send a feedback from the .dll to the interface ?
Maybe a progress bar, or after reading the elements, display them on the interface, before crawling the next element ?
What i want is something like that to be displayed on the interface (gridview or something), in real time.
Finished Crawling College X
Finished Crawling College Y
Problem Crawling College Z - ABORTING
Finished Crawling College K
and so on.
Whats a good way for doing it ?
I thought about sending the reference of the Visual Component to the .dll (or to a secundary .dll) so that it can update the visual component itself, in the middle of the execution. Is there any downside of doing it ? Do i break any good pratice by doing so ?
Thanks in advance,
Marcello.
Basically, you could do something like this:
And have some class in your DLL that implements this. You then pass in a callback that your crawler class can invoke to send messages back to the invoker.
In your callback, you can then take the data passed to you and update the UI by invoking the UI updates asychronously, even from multiple crawlers.