?
Solved

From loop send to endless loop

Posted on 2013-06-26
5
Medium Priority
?
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

770 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