开发者

Using threads and event handlers within a WCF Web Service

While making a WCF Web Service, I came across a problem while using a method with a webbrowser control. The method starts a thread and uses a w开发者_运维知识库ebbrowser control to fill in some forms and click further, waiting for a event handler to fire and return a answer I need. The method is tested and works within its own enviroment, but used in a WCF Web Service enviroment, the event handlers just won't fire. A result of that is the waiting manualresetevent not ending. Is this because of the new thread or because of the bad event handling of the web service? If yes, what is a reasonable solution?


Browser1 --> Web App --> Web Service --> do action on other site (new Browser --> open url --> Fill in URL --> press ok --> catch response --> process answer)

if the part of your system that creates a "new browser" is running as a service, either as a Windows Service, a self-hosted WCF service process, or something inside of IIS; then more than likely you won't get GUI events because there is no GUI. GUI event handlers, amongst other things, require a Windows Message Pump which is not available in these scenarios.

try hosting your service under say a Windows Forms host to see, I suspect it will work.

If you must have your system under IIS or a Windows Service (non-GUI) then you could always communicate to a surrogate host process which has a message pump where it could do all the browsing stuff for you. once complete your "answer" could be sent back to the web app

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜