Note that there are some explanatory texts on larger screens.

plurals
  1. POWhile loop causes the app to go slow? Any idea why?
    primarykey
    data
    text
    <p>I have a simple code that looks up a text file, reads the line of text, splits the string by semi-colons and then posts the results.</p> <p>After it has done this, I have created a really simple while loop to waste 10 seconds before going for it again.... here is the code:</p> <pre><code>Private Sub checkTemps() While Abort = False Try fileReader = New StreamReader(directory.Text &amp; "currentTemp.dat") rawData = fileReader.ReadLine() fileReader.Close() Dim dataArray() As String dataArray = rawData.Split(";") updateOutput("1", dataArray(0), dataArray(1)) updateOutput("2", dataArray(2), dataArray(3)) updateOutput("3", dataArray(4), dataArray(5)) updateOutput("4", dataArray(6), dataArray(7)) stpWatch.Start() While stpWatch.Elapsed.Seconds &lt; 10 And Abort = False pollInterval(stpWatch.ElapsedMilliseconds) End While stpWatch.Stop() stpWatch.Reset() Catch ex As Exception msgbox("oops!") End Try End While closeOnAbort() End Sub </code></pre> <p>But when it gets to the "time-wasting" loop - it seems to slow the whole application down? And I can't work out why!</p> <p>So a couple of questions... is there a better way to do all this? and second - can anyone spot a problem?</p> <p>All the other commands seem to run fine - there isn't much else to this app. I have another program that updates the dat file with the values, this is simply a client side app to output the temperatures.</p> <p>Any help would be appreciated.</p> <p>Andrew</p> <hr> <p>More info:</p> <p>I should explain what the pollInterval sub does!</p> <pre><code>Private Delegate Sub pollIntervalDelegate(ByVal value As Integer) Private Sub pollInterval(ByVal value As Integer) If Me.InvokeRequired Then Dim upbd As New pollIntervalDelegate(AddressOf pollInterval) Me.Invoke(upbd, New Object() {value}) Else ProgressBar1.Value = value End If 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.
    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