With a little help from Google and combining suggestions and tricks from different sources, we compiled a nice solution.
1.Creation of static HTML page
First of all, we created a static HTMLpage HTMLPage1.html with all the relevant scripts definitions. In following example, we’ve created a sample page with 2 references:
2.Running WebBrowser control
Next step is to create and to execute the WebBrowser control in our module.
WebBrowser is a Windows.Forms control, as such it should be executed as Single-Threaded Apartment (STA) process.
The following code will do the trick:
3.Calling the module and using the callback
4.Sample client code:
Here we created a CallBack object and subscribed to its ResultArrived event (just prints the results to Output).
Then, we just called to our module. Notice how the parameters and especially CallBack instance were passed (the CallBack instance is the last parameter !).
That’s all! Simple and elegant solution for pretty tricky problem.
But there is still one big con for this solution and it’s of course the use of the WebBrowser control.
Yes, memory leak issues are still there and weren’t solved (online discussion thread: http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/88c21427-e765-46e8-833d-6021ef79e0c8).
However if it runs for hours and performs thousands calls to a module above then depending on your machine it can hang or stuck.