Solved

From loop send to endless loop

Posted on 2013-06-26
5
317 Views
Last Modified: 2013-06-26
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
Comment
Question by:lrbrister
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39279502
You can execute that method on a separate thread.
0
 

Author Comment

by:lrbrister
ID: 39279513
CodeCruiser,
  That's what I thought..and what I don't know how to do.

You have a link?"
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39279542
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
 

Author Closing Comment

by:lrbrister
ID: 39279593
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
 

Author Comment

by:lrbrister
ID: 39279687
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now