Solved

From loop send to endless loop

Posted on 2013-06-26
5
313 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
Comment Utility
You can execute that method on a separate thread.
0
 

Author Comment

by:lrbrister
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

10 Experts available now in Live!

Get 1:1 Help Now