473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Wait for a function to run and then continue (ping)

I am programing a ping application which pings various centers . I
used timer loop and it pings one by one.

Now when i finish pinging one center it should wait for the
ping_completed function to be executed and then continue pinging
another certer.

The ping_completed function is called on completion of ping by the os
and i have no control on it .

Wait for a function to run and then continue.
(the ping application is developed from the msdn samples)

Feb 11 '07 #1
5 5557
"Deepak" <de*********@gmail.comwrote in news:1171221409.321605.259670
@a34g2000cwb.googlegroups.com:
I am programing a ping application which pings various centers . I
used timer loop and it pings one by one.

Now when i finish pinging one center it should wait for the
ping_completed function to be executed and then continue pinging
another certer.
So you'll like to block the ping function?
Feb 11 '07 #2
On Feb 12, 3:26 am, Spam Catcher <spamhoney...@rogers.comwrote:
"Deepak" <deepak.m...@gmail.comwrote in news:1171221409.321605.259670
@a34g2000cwb.googlegroups.com:
I am programing a ping application which pings various centers . I
used timer loop and it pings one by one.
Now when i finish pinging one center it should wait for the
ping_completed function to be executed and then continue pinging
another certer.

So you'll like to block the ping function?
no i dont want to block it . the ping completed function runs by
itself after some time.
i want to make it wait until the ping completed function runs and then
continue pinging another center.

Feb 12 '07 #3
"Deepak" <de*********@gmail.comwrote in news:1171258144.907950.54910
@l53g2000cwa.googlegroups.com:
no i dont want to block it . the ping completed function runs by
itself after some time.
i want to make it wait until the ping completed function runs and then
continue pinging another center.
If you want to make Ping "wait" then you're block the thread?

Do you want multi-threading (i.e. multiple pings at once) or do you want to
ping the centers one at a time (single threaded - blocking?).
Feb 12 '07 #4
On Feb 12, 10:33 am, Spam Catcher <spamhoney...@rogers.comwrote:
"Deepak" <deepak.m...@gmail.comwrote in news:1171258144.907950.54910
@l53g2000cwa.googlegroups.com:
no i dont want to block it . the ping completed function runs by
itself after some time.
i want to make it wait until the ping completed function runs and then
continue pinging another center.

If you want to make Ping "wait" then you're block the thread?

Do you want or do you want to
ping the centers one at a time
Sorry to reply late ,
ping the centers one at a time (single threaded - blocking?). as u
say. I don't know much about threading
here are the functions used
1 ) the ping completed one
Private Sub pingClient_PingCompleted( ByVal sender As Object,
ByVal e As PingCompletedEventArgs) _
Handles pingClient.PingCompleted
' Check to see if an error occurred. If no error, then
display the
' address used and the ping time in milliseconds
2 ) Private Sub sendPingButton_Click( ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
sendPingButton.Click
'it contains a loop with this command
pingClient.SendAsync(address1.Text, Nothing)
there are many text boxes (address2, address3,etc)

Now when the loop starts the first address is pinged . before the ping
completed is called for the first address the second address gets
pinged
I want it to wait till the ping completed function gets called and
then ping the second address.

Feb 12 '07 #5
Deepak wrote:
I am programing a ping application which pings various centers . I
used timer loop and it pings one by one.

Now when i finish pinging one center it should wait for the
ping_completed function to be executed and then continue pinging
another certer.

The ping_completed function is called on completion of ping by the os
and i have no control on it .

Wait for a function to run and then continue.
and then added:
1 ) the ping completed one
Private Sub pingClient_PingCompleted( ByVal sender As Object,
ByVal e As PingCompletedEventArgs) _
Handles pingClient.PingCompleted
' Check to see if an error occurred. If no error, then
display the
' address used and the ping time in milliseconds
2 ) Private Sub sendPingButton_Click( ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
sendPingButton.Click
'it contains a loop with this command
pingClient.SendAsync(address1.Text, Nothing)
there are many text boxes (address2, address3,etc)

Now when the loop starts the first address is pinged . before the ping
completed is called for the first address the second address gets
pinged
I want it to wait till the ping completed function gets called and
then ping the second address.
Instead of calling SendAsync from inside the button click handler, I'd
suggest you use a separate method, so you could call it from the
PingCompleted event handler as well. At each call, the method would
retrieve the next address in line from a global list and ping it.
Something in the lines of:

<aircode>
Private mPingsPending As New Queue(Of String)

Private Sub PingNext
If mPingsPending.Count = 0 Then
'... finished pinging.
'restore the UI, or whatever
Else
Dim Address As String = mPingsPending.Dequeue
PingClient.SendAsync(Address, Nothing)
End If
End Sub

Private Sub SendPingButton_Click( _
... _
) Handles SendPingButton.Click
'... 1) Get all addresses from wherever they are
'... 2) Add each address to mPingsPending:
'... mPingsPending.Enqueue(Address)
'... 3) Disable the UI, or whatever
'... 4) Ping'em!

PingNext
End Sub

Private Sub pingClient_PingCompleted( _
... ) Handles pingClient.PingCompleted
' Check to see if an error occurred. If no error, then
'display the address used and the ping time in
'milliseconds
'Continue pinging:
PingNext
End Sub

</aircode>

HTH.

Regards,

Branco.

Feb 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Denis Hierstein | last post by:
I need a function, witch make a break in a for-loop and wait for the <enter>-key ... when I use Pascal I just use the Read; or the ReadLn;-function, then the loop stop as long as the user push the...
4
by: GTi | last post by:
Hello... I have a page located in a frame. This page contains a form. When the user submit this form I want to popup a "Please Wait" window popup window The post may take some time for the...
11
by: Pelo GANDO | last post by:
Hi everybody, It's me again...Pelo, for an other beginner question... What the code should be in C++ to wait for a keyboard entry in order to execute the sequal of my program...
4
by: PinellasBoy | last post by:
I have an stored procedure which takes long time to execute. So I am trying to execute the procedure in another thread by using the thread start function. After the SP starts processing I want to...
12
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock...
1
by: LuisRibeiro | last post by:
Hello. I'm building an intranet the is going to be used to perform network tests. The tests are FTP,HTTP,PING, etc. I need to do sequences of this tests, but i need that a test only starts, when...
22
by: Jason Zheng | last post by:
This may be a silly question but is possible for os.wait() to lose track of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20 (i686), gcc4.1.1, and glibc-2.5. Here's what happened...
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
2
by: foster99 | last post by:
I am new to VB.NET and I want to implement a timer function into a PING, below is the code which I am using to PING an ip address. I want the PING to be executed something like every 10 seconds, so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.