Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are few things that look like a good place to start.</p> <p>1) Pull the code after ScrubMessage into it's own function which takes the needed information as parameters. Then replace all the GoTos with calls. This probably will not improve performance, but makes the code easier for most people to understand (and convention says raw gotos are evil).</p> <pre><code>Sub ScrubAndSendMessage(response As String, client As YahooClient) 'code after label here with needed local variables End Sub </code></pre> <p>2) You are searching through a list for every word of every incoming message. Based on the usage, KeywordInd and m_nodelist are probably declared something like this:</p> <pre><code>Dim KeywordInd As List(Of String) Dim m_nodelist As List(Of XmlNode) 'or whatever type has the inner text </code></pre> <p>Since the keyword list seems to be a key into the node list of values, I would suggest using a dictionary to simplify the code and potentially improve speed.</p> <pre><code>Dim wordResponse As New Dictionary(Of String, String) </code></pre> <p>where the keys are the words from <code>KeywordInd</code> and the values are the <code>InnerText</code> from <code>m_nodelist</code> which lets you say</p> <pre><code>For Each word In msgSplit If wordResponse.ContainsKey(word) Then ScrubMessage(wordResponse(word)) Exit Sub End If Next </code></pre> <p>3) Try associating the conversation directly with the YahooClient object so you do not have to do the lookup every time to find the conversation. When you do that, you can also make sure that there is a <code>Conversation</code> associated with every client if desired.</p> <p>4) You are interacting directly with what look to be UI components in the handler. This requires that all handlers for all clients run on the UI thread. You would probably be better of raising some events from this handler and letting the form handle the events and post across to the UI thread as needed. The events would probably be <code>ScriptPositionAdvanced</code> and <code>ResponseSent</code> or something similar. The form/control could then handle these events and post to the UI thread according to the pattern used by your UI framework of choice, which you should be able to find with a quick search.</p>
    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