WebBrowser memory problem

后端 未结 3 988
悲哀的现实
悲哀的现实 2020-12-10 16:54

I have a .NET application that needs uses a WebBrowser to automatically navigate through a bunch of pages. But if I go to, for instance, Google and set Google I

3条回答
  •  时光取名叫无心
    2020-12-10 17:18

    when working with Webbrowser, i found that it is important to wait for the "documentcompleted" event and check if the "state" is "completed" bevore navigating no next page. Else cancel navigation and wait again for document-completed state (aborted ) bevore navigating....

    could be that the use of timers and not checking the Webbrowser's state could be a problem

    the next thing with the Webbrowser-Control is, that you cannot use it in multithread / Backgroundworker since it requires to be STA....( often makes problems with unresponsive application )

    the solution for "ful-contol" (parsing websites ) using .NET for me, was to use WebRequest / Webresponse , you can cast the result of that to Webbroswer.Document again if you want the DOM to be "auto" executed , use it multithreaded , easyly set timeouts / proxy wich i found more comfortable than using Webbrowser-control.

    Nevertheless i sucessfully implemented a Webbrowser-Control parsing pages in another project using hints from here ( How to Fix the Memory Leak in IE WebBrowser Control?)

    another "funny" thin with Winforms-programming i found out is, that it seems that a GC.Collect is triggered when the window is minimized an opened again - > does this decrease the mem-usage ? ( maybee Stefan's post also references to this issue )

提交回复
热议问题