Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET Application Freezed and not running
    primarykey
    data
    text
    <p>I have an application that uses a loop to call a new thread with some parameters, the application is great but when it comes to 100,000 records or so the application is not running (in the CPU and memory taskmgr not change, therefore assume that the program is not working)</p> <p>The action is: It runs a function that first collects a number (X) and then create a loop from 0 to X, within this loop we create a new Thread and options as indicated IsBackground (True), Priority (Normal), and initialize the thread. In the same function Thread.Join have a Do While (true) and if you can cross it refreshed interface, abort thread, memory clean and DoEvents!</p> <p>Within the thread use a WebClient to OpenRead and keep all this in a Stream. With WebClient.IsBusy = False Do While we ensure that the information is downloaded and proceed to make a MatchCollection with Regex.Match. Using a For Each the match and print results, and ended Exit Do.</p> <p>Then returns to the function that tells a while back ...</p> <p>At first I thought it was because of the number of results that were printed in the listbox but I got it and still fails, not when it reaches the 100,000 records if not the 100,800 or so.</p> <p>I need help, I don't know very well programming in vb.net and not understand why.</p> <p>EDIT: I tried remove the For Each of thread, check whether it was. It has emerged completely, but I do not understand why it happens not even give me an error when "For Each" in the thread ¿solutions?</p> <hr> <p>EDIT: I found the bug, but i don't understand i explain:</p> <p>A) --> Initialize function with For 0 to 4500, i call a thread with parameters and receive 50 results, ( 225000 registers &lt;- 4500 * 50 ) when the principal For arrive to ~ 4000, in MatchCollection in Thread ¿fails? i don't receive the info of Regex.Matches and then freezed.</p> <p>B) --> Initialize function with For 4000 to 4500, i call a thread with parameters and receive 50 results, ( 225000 registers &lt;- 4500 * 50 ), nothing more begin the first thread ( remember now begin with 4000 to 4500 and i have receive a 25000 registers ) the program is freezed and i check with break points and fails the variable containing the results of Regex.Matches and attempting looping the that array the program are freezed!</p> <p>¿Why? ¿Solutions?</p> <p>Thanks!!</p> <hr> <p>Function 1 (Inicialize Thread)</p> <p>Function 1 -></p> <pre><code>For Me.d = 0 To Pages(0) ' &lt;-- 4500 Dim param(1) As Object param(0) = "name" param(1) = "url/" &amp; d Dim thread As New Thread(AddressOf Thread_) thread.IsBackground = True thread.Name = "name" thread.Priority = ThreadPriority.Normal 'ThreadPriority.Lowest thread.Start(param) Do While thread.Join(True) thread = Nothing ClearMemory() Application.DoEvents() Exit Do Loop Next d </code></pre> <p>The Thread function:</p> <pre><code>Public Sub Thread_(ByVal param As Object) Try If param(0) = "name" Then Using Client As New WebClient Client.Headers("User-Agent") = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1290.1 Safari/537.13" Dim html As Stream = Client.OpenRead(param(1)) Using reader As New StreamReader(html) Do While wc.IsBusy = False Dim ReadStr = reader.ReadToEnd links = Regex.Matches(ReadStr, "coderegex", RegexOptions.Compiled + RegexOptions.RightToLeft + RegexOptions.Multiline + RegexOptions.Singleline) For Each match In links Registres(0) = Registres(0) + 1 Debug.Print("Registro: " &amp; Registres(0) &amp; " pág:" &amp; PagesComplete(0)) Next PagesComplete(0) = PagesComplete(0) + 1 links = Nothing Client.Dispose() Exit Do Loop End Using End Using End If Catch ex As Exception Debug.Print("Error " &amp; ex.Message) End Try End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload