473,657 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5580
"Deepak" <de*********@gm ail.comwrote in news:1171221409 .321605.259670
@a34g2000cwb.go oglegroups.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...@r ogers.comwrote:
"Deepak" <deepak.m...@gm ail.comwrote in news:1171221409 .321605.259670
@a34g2000cwb.go oglegroups.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*********@gm ail.comwrote in news:1171258144 .907950.54910
@l53g2000cwa.go oglegroups.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...@r ogers.comwrote:
"Deepak" <deepak.m...@gm ail.comwrote in news:1171258144 .907950.54910
@l53g2000cwa.go oglegroups.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_Ping Completed( ByVal sender As Object,
ByVal e As PingCompletedEv entArgs) _
Handles pingClient.Ping Completed
' 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.EventArg s) Handles
sendPingButton. Click
'it contains a loop with this command
pingClient.Send Async(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_Ping Completed( ByVal sender As Object,
ByVal e As PingCompletedEv entArgs) _
Handles pingClient.Ping Completed
' 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.EventArg s) Handles
sendPingButton. Click
'it contains a loop with this command
pingClient.Send Async(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.C ount = 0 Then
'... finished pinging.
'restore the UI, or whatever
Else
Dim Address As String = mPingsPending.D equeue
PingClient.Send Async(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.E nqueue(Address)
'... 3) Disable the UI, or whatever
'... 4) Ping'em!

PingNext
End Sub

Private Sub pingClient_Ping Completed( _
... ) Handles pingClient.Ping Completed
' 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
24332
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 <Enter>-key.
4
12888
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 server to process. So when the new windows is loaded into the browser, I want to close this Wait window. I have found a global JavaScript variable I may use.
11
18236
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
1856
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 take the user to a "wait" page and then return them after the processing is over. The wait page has http-refresh header which takes it back to the starting page. Once the starting page has reloaded in page_load procedure I would like to check...
12
5261
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 block protecting a resource. Thread 2 and 3 also have a SyncLock block protecting the same resource and after executing some code in their blocks they both do a Monitor.Pulse to hand of the locked resource back to thread 1. While thread 1 has...
1
1761
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 the previous test had finished. Is it possible to create a wait execution function?
22
11744
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 in my situation. I first created a few child processes with Popen, then in a while(True) loop wait on any of the child process to exit, then restart a child process: import os from subprocess import Popen
6
3454
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 wondering if anyone has a ping function they could share with me. I have done some searching on this but cannot find anything specifically for vb2003. Sub PingComputer If PingStatus(PCName) = "Success" Then
2
1757
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 that it updates a lablel. Any ideas how to do this? Dim ping As New System.Net.NetworkInformation.Ping Dim options As New System.Net.NetworkInformation.PingOptions options.DontFragment = True
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.