Lukket

Access violation Issue in MultiThreading

**Description:** The Access violation Issue in MultiThreading

Language: VB .NET 2005

Description:

We are creating an instance of webbrowser control object internally in the code, and assign an html text to its “DocumentText?? property. When the [url removed, login to view] = [url removed, login to view], we are accessing the parsed html Document object and using it for some operations.

The Webbrowser control is not in the GUI , it is created dynamically and never displayed.

## Deliverables

**Description:** The Access violation Issue in MultiThreading

Language: VB .NET 2005

Description:

We are creating an instance of webbrowser control object internally in the code, and assign an html text to its “DocumentText?? property. When the [url removed, login to view] = [url removed, login to view], we are accessing the parsed html Document object and using it for some operations.

The Webbrowser control is not in the GUI , it is created dynamically and never displayed.

We are using multithreading and every thread created does the above process. These threads work independently , and their appartment state is STA ([url removed, login to view]).

The process in the thread reads HTML tags and parse them using the webbrowser object created.

Problem:

The threads gets created and starts fine. After a few iterations we gets the error

“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.??

And the StackTrace of the Exception was

[url removed, login to view]()

at System.Windows.Forms.WebBrowser.get_Document()

at System.Windows.Forms.WebBrowser.get_ReadyState()

Tried Fixes:

[url removed, login to view] the webbrowser object

Shared wbAds As WebBrowser

2. Called [url removed, login to view]() after every iterations

[url removed, login to view] the Thread Sleep interval.

This fixes didn’t sloved the problem

Our Code model with threading

Private sub subThreadCaller()

Dim trdAnalysis() as Thread

Dim i,j as int16

J=5

Redim trdAnalysis(j)

For i = 0 To j

trdAnalysis(i) = New Thread(New ThreadStart (AddressOf subProcWeb))

trdAnalysis(i).SetApartmentState([url removed, login to view])

trdAnalysis(i).Name = "Thread" & i

trdAnalysis(i).IsBackground = True

trdAnalysis(i).Start()

[url removed, login to view](50)

Next i

End Sub

Private Sub subProcWeb()

Dim wbo As WebBrowser

Dim htmlDoc As HtmlDocument

Dim strHtm as string

Dim i, j as int32

J=1000

For i = 0 to j

strHtml =

wbo = new WebBrowser

[url removed, login to view] = strHtml

[url removed, login to view] = True

While Not [url removed, login to view] = [url removed, login to view]

[url removed, login to view]()

[url removed, login to view](1000)

End While

While [url removed, login to view] = True

[url removed, login to view]()

[url removed, login to view](1000)

End While

htmlDoc= [url removed, login to view]

... Processing follows...

[url removed, login to view]()

[url removed, login to view](100)

Next i

End Sub

Our Requirement is to check our web pages for a certain condition .

For this we read the HTML source of the page and assigin it to a webbrowser object.

Then check the parsed htmldocument.

Since analysising the HTML Document object was most suited for our need than using regular expression on the html source file.

Thanks

Evner: .NET, Ingeniørarbejde, MySQL, PHP, Software Arkitektur, Software Testning, Visual Basic

Se mere: webbrowser multithreading, using regular expression, string processing in c, string j, regular expression using, regular expression starts with, regular expression no, regular expression in c, regular expression code, regular expression c, regular expression a, regular expression 0, c++ parse html 5, webbrowser, violation, redim, parse an html, multithreading, in process access, appartment

Om arbejdsgiveren:
( 0 bedømmelser ) Kuwait, Kuwait

Projekt ID: #3324163

3 freelancere byder i gennemsnit $99 på dette job

shawnburt

See private message.

$127.5 USD in 14 dage
(117 bedømmelser)
6.5
MoonSoftware

See private message.

$85 USD in 14 dage
(49 bedømmelser)
5.4
irfanazam

See private message.

$85 USD in 14 dage
(21 bedømmelser)
3.7