[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

From loop send to endless loop

I have a while statement that will run x times
Inside the While I want to kick off another sub or function (or thread???)
The problem is that the other sub is a monitoring sub...essentially an endless loop

So once I send to the sub  - sendToEndlessLoopSub(sendWebRequest, sentPostData)
It never goes to the next "While"

The sub starts with this
            Dim sendWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

            sendWebRequest.SendChunked = True
            sendWebRequest.Method = "POST"
            sendWebRequest.ContentType = "text/plain"
            sendWebRequest.KeepAlive = True
            sendWebRequest.UserAgent = "CometTest"


Then to the While

While ii < row.count -1
    sentPostData = newCommandData
    sendToEndlessLoopSub(sendWebRequest, sentPostData)
End Wile

Console.Write(ControlChars.Cr + "All " & numProcesses & "Processes are running" + ControlChars.Cr)
0
lrbrister
Asked:
lrbrister
  • 3
  • 2
1 Solution
 
CodeCruiserCommented:
You can execute that method on a separate thread.
0
 
lrbristerAuthor Commented:
CodeCruiser,
  That's what I thought..and what I don't know how to do.

You have a link?"
0
 
CodeCruiserCommented:
Change this

sendToEndlessLoopSub(sendWebRequest, sentPostData)

to

Dim th As New Thread(AddressOf sendToEndlessLoopSub)
th.Start(arguments)

You will have to reduce the parameters to 1

http://msdn.microsoft.com/en-us/library/6x4c42hc.aspx
0
 
lrbristerAuthor Commented:
That answered this question and gets me in the thread.

I'm error-ing out on that process itself.

Will try and bludgeon my way through it the rest of today and may have a new question in the morning.

Thanks.
0
 
lrbristerAuthor Commented:
CodeCruiser,
  You have no idea how much you helped over the last week.

While this is in dev, I have a solution working that I can streamline and move into a service now.

The problem was that I had a large set of phones that had to be monitored for our sales team and the data sent to SQL Server

The vendor only allowed 7 phones to be in a  "waitingtostart" monitoring status at a time

So I had to send the groups of 7 phones in a web request about 5 seconds apart

The response on each one had to be kept open so they can read straight into sql

That was the "While response.CanRead" answer you gave me the other day.

So,
I now have my loop, starting the threads, which stay open...and receive data.

Truly...thank you so much.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now