[2005] Ping And Return Value With Async Calls?

Feb 3, 2009

I am trying to run this

vb
Public Sub SendPing(ByVal strHostname As String, ByVal objSelectedNode As TreeNode)
Try
Dim objPing As New Ping

[code]....

My problem is that in this code (and I know it's a lame way to do it) I'm checking to see if the node is Green after the Ping has been completed to determine if the ping was successful. I would prefer to return a boolean value to be True if the ping was successful.

When it executes the SendPing on the DragDrop function, it starts that thread and executes the If statement to determine if the node is green, but the ping isnt complete. Now I have to do this function on many nodes at once, so I dont want this to be a single thread. Is it possible to return a value from an async call and then execute a function after that value has been returned, or will this have to be a single thread?

View 7 Replies


ADVERTISEMENT

VS 2005 Async Ping Request

Jun 3, 2009

I am using a DataGrid object that updates every 2 seconds using a timer control.I am trying to have the ping request sent asynchronously to speed up the process. I'll explain what I am trying to do in the code in rem statements..[code]

View 6 Replies

VS 2008 ASYNC Ping - Writing To TextFile?

Dec 6, 2009

I was trying to edit to get the reults output to a text file. I needed to do this for a few hundred IP addresses, and found kleinma's code. It works great as is, but since the number of IP addresses to ping is so large, I lose some of the info from the console session. I tried to make changes to write the information into a text file, but it doesn't output the results. I am relatively new to VB.NET, so I was wondering if you could please point out the flaw(s) in the edited code. I was trying to use the My.Computer.FileSystem.WriteAllText(File, lineContent, True) method to do this. This does export the IP address list just fine, but the results of the async ping to not get output.

'KLEINMA
'WWW.VBFORUMS.COM
'THE PING CLASS IS IN THIS NAMESPACE
Imports System.Net.NetworkInformation

[code]....

View 1 Replies

Clean Up App And Deal With The Async Calls?

Mar 16, 2010

My app is basically talking to a device via RS232. I need to 'listen' to the data received and do certain things based on it, update labels, etc. When I started, I only had a couple cross-thread calls and I used JMC's example to get by that. Now my app is bigger and I am calling the ThreadProcSafe all the time. I am hoping there is an easier way so I don't have to create sub routines for every control. Here's the relevant parts of my code.

Private Sub StepperSerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles StepperSerialPort.DataReceived
Dim ReceiveBuffer As String

[Code].....

View 4 Replies

Cannot Make Twitter Calls Using Twitterizer Silverlight/Async

Jan 26, 2012

Using the code example on the Twitterizer website I am trying to post a tweet to twitter with this code:

Dim asyncResult As IAsyncResult = TwitterStatusAsync.Update(
tokens.Tokens,
Tweet.Text,

[Code]....

View 1 Replies

Delegate - BeginInvoke - EndInvoke - Clean Up Multiple Async Threat Calls To The Same Delegate?

Feb 9, 2010

I've created a Delegate that I intend to call Async.

[Code]...

View 2 Replies

Loop To Ping A List Of Ip's Return The Results And Save Them To An Access Db

Aug 6, 2009

Sorry for new thread--i have this code, basically a loop to ping a list of ip's return the results and save them to an access db:

[Code]...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code]...

View 24 Replies

Ping Using Vb.error - Ping An Ip Address And Store The Result In An Access Db

Jul 8, 2009

i have tried altering some code i have to ping an ip address and store the result in an access db.i had it working when i had the ip hardcoded in as a string but I am now gettin an error.instead of having the ip address hardcoded in to the code i want it to be read in from the access db but im now getting this error:System.nullreferenceExceptionbject reference not set to an instance of an object at...button1.click event args ei have underlined the piece of code i tried to change

Imports System.Data

Public Class Form1

Dim Ping As Net.NetworkInformation.Ping

[CODE]...

View 39 Replies

VS 2008 Execute A CLI Program And Have It Output Or Return What The CLI Program Saids Such As Ping Etc?

Apr 25, 2009

Is there a way i can execute a CLI program and have it output or return what the CLI program sais, such as ping etc.

View 3 Replies

2005 Ip - Ping A Server And See If There Is A Response

Oct 21, 2009

im trying to do is ping a server and see if there is a response. If there is a response then i would like to set an integer to 1 if there is not a response set the integer to 0. I would also then like to gather any servers that had a response into a list box. I know how to build a list box just having trouble getting the code to set a variable if or if there isnt a response.

View 4 Replies

Making An Async Function Not Async?

Jun 3, 2010

I'm trying to write a 'developer friendly' wrapper for the Windows API EnumWindows - the problem is that the API uses a callback function that gets invoked on another thread, where as I want my wrapper function to simplify this and make it more useful by working like any other normal synchronous function and just returning a value.

Now if the API just called the callback once that would be fine, as I would just call the API and make the wrapper function wait until it got a signal from the callback function telling it to continue... but the API calls the callback function over 100 times (once for every window handle that exists). The biggest problem is that there is nothing that indicates that any particular call to this callback function is the last one, so my wrapper function has no idea when it is safe to continue and return the list of window handles to the caller.

The only solution I could think of is to do this:

1. The wrapper function calls the API and starts a timer that waits 2 seconds before it raises the Elapsed event. The wrapper function then pauses until it receives a signal (ManualResetEvent)

2. Each time the callback function is raised by the API on a different thread, it stops the timer (so this is before the 2 seconds have elapsed), adds the current window handle that was passed in by the API to the list of handles, then starts the timer again.

3. If the timer reaches its 2 second interval then it is assumed that we are at the end of the windows because otherwise the callback would have stopped the timer. So the timer's Elapsed event handler is what signals the original thread (that the wrapper function is executing on) to continue as we now have a complete list of windows to return.

This works fine and does exactly what I want... but I dont like it.

I dont like forcing the caller to wait an extra 2 seconds after the API has done its last callback but more importantly I dont like assuming that the API will never take longer than 2 seconds between callbacks. In reality on my PC it is never anywhere near that long between callbacks, it is something like 200 miliseconds, but I have no idea how long it would be on a slower PC and I want this to be completely reliable.

[URL]

View 14 Replies

VS 2005 - How To Replicate Ping In Command Prompt

Nov 19, 2010

I need to replicate the ping in command prompt. I'm currently using the following:
Try
If My.Computer.Network.Ping(mtbIPAddress.Text) Then
rtbLog.AppendText("Response")
Else
rtbLog.AppendText("Reject")
End If
Catch ex As Exception
rtbLog.AppendText("Reject")
End Try

But I need to get the same response as the ping in command prompt i.e..
Pinging www.l.google.com [74.125.71.104] with 32 bytes of data:
Reply from 74.125.71.104: bytes=32 time=240ms TTL=53
Reply from 74.125.71.104: bytes=32 time=313ms TTL=53
Reply from 74.125.71.104: bytes=32 time=256ms TTL=53
Request timed out.
Reply from 74.125.71.104: bytes=32 time=251ms TTL=53
How do I get the bytes, time and TTL?

View 7 Replies

Win32 API - Equivalent To Making System Calls Abd And Library Calls In UNIX?

May 8, 2010

What the Win32 API is? I have looked around but no where really outlines what it is. Is it basically a set of procedures, outlined by Microsoft for programmers in order to get services from the operating system? In essence is it the equivalent to making system calls abd and library calls in UNIX? And yes I now Windows makes library calls too.

View 2 Replies

Replacing DbTransaction Calls With Calls To TransactionScope?

Mar 4, 2010

I have been using DBTransaction for my current projects that access a single database. However, I read some documentation on TransactionScope and was wondering in which scenario would using TransactionScope be better? Or should I be replacing DbTransaction calls with calls to TransactionScope?

View 2 Replies

VS 2005 - How To Call A Return From A Class From A Sub

Oct 24, 2009

I have a Class in a Windows Form project. I would like to call the class return value from the Form1 sub on button click. How do I do that? Lets say I would like to display the Return in a MsgBox?

View 4 Replies

VS 2005 - How To Return ID Number Of Inserted Row

Nov 30, 2010

I've just intserted a row into a database, how can i return the ID number of that row that's just been inserted?
Here is my insert code
vb.net
Dim command As New OleDb.OleDbCommand("INSERT INTO StaffData(PaxTitle, FirstName, Middlename, Lastname, DOB, @LastUpdated)", connection)
command.Parameters.AddWithValue("@PaxTitle", TitleTxt.Text)
command.Parameters.AddWithValue("@FirstName", FirstnameTxt.Text)
command.Parameters.AddWithValue("@MiddleName", MiddlenameTxt.Text)
command.Parameters.AddWithValue("@LastName", LastnameTxt.Text)
command.Parameters.AddWithValue("@DOB", DOBTxt.Text)
command.Parameters.AddWithValue("@LastUpdated", Now.ToString)

View 8 Replies

VS 2005 - Return Value ID From Insert Statement

Aug 12, 2009

Dim SQLData As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("FixedLineProvisioningConnectionString").ToString())
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("INSERT INTO tblTotalComms_custinfo SET nt_username=@nt_username; SELECT @ID=SCOPE_IDENTITY()", SQLData)
[Code] .....
I want to return the value @ID from the insert statement.

View 7 Replies

VS 2005 Custom Return Value From Dialog Box?

Apr 7, 2009

i am creating my own message box. My msgbox contains 4 button , so i want to return an integer value as the button no. that was selected (i.e return 1 for button 1, 2 for btn 2...)i tried me.dialogresult=1 , but its not working

View 4 Replies

VS 2005 Function Return Structure Value

Dec 22, 2009

I want my function to return a value of a structure. The function is supposed to change the values and then return the answers in one structured value. Here is my code... as you can see it does not work... it needs a LOT of things. I placed question marks were i am really lost.

[Code]...

View 13 Replies

VS 2005 Return The Button Pressed

Jun 29, 2010

On an form i have few labels, upon clicking on that labels i want to display an another form which contains 3 textboxes(Default,Current,New) and 3 buttons(Default,Current,new). I need to save the values of all the textboxes to the label's tag, but the label's text will contain the value of the textbox based upon the button which is pressed. i.e if 'Default' button is pressed then the 'Default' textbox text should be the label's text. I have created a class with three mem. variables to the save these class objects in the labels tag. But how should i know which button was pressed.

View 3 Replies

VS 2005 - Return Value From Asynchronous Web Service Call

Aug 13, 2009

I'm using ASMX web services in VB.Net in VS 2005. I am calling a function method on the web service that returns a true or false value. This works fine if I call the the web method synchronously, but if I want to call the method asynchronously, the function returns to a sub and there is no return value; therefore, I can't tell whether the result of call is true or false. Is there a way to make an asynchronous call and still get the true or false result (perhaps using the userState Object)?

For Example:
Dim MyResult as Boolean = MyService.GetResult(10)
Dim MyResult as Boolean = MyServer.GetResultAsync(10)
This doesn't work the compiler complains: "Expression Does Not Produce a Value"

View 2 Replies

VS 2005 Return Type Of Custom MsgBox?

Apr 29, 2010

I am building my own Message Box, I have overloaded the ShowDialog function and i wish to Change the Return Type from DialogResult to my own.To do so , shall i declare an Public Enum within the form and set it as the Return Type, or is there any other proper way?

View 2 Replies

VS 2005 - How To Capture Return Code From Shell Command

Aug 25, 2009

If I execute any shell command in VB application How can I capture the return code from the shell command. I have written something like this
shell(db2look ....,AppWinStyle.Hide)
Now I want to know the return code of the above command which ran using shell script.

View 1 Replies

VS 2005 Function Return Types And Error Conditions

Jun 8, 2012

Lets say I click a button on a form that calls a function in a data access class. This function inserts a record into a table in a database. The function returns an integer value for the record id of the newly inserted record. Now lets say the insert failed (syntax error, timeout, whatever). I can return a zero to the calling routine to indicate the failure, but not the error message. So in general, what's the most appropriate way to handle getting information back to a calling routine when the return parameter data type doesn't allow it?

View 3 Replies

C# - Using Async Methods Asp.net?

Jul 15, 2010

I have two methods on the page. One AddMessageToInboxOutbox(params[]) and other one SendNewMessageMail(params[]).

Once user sends an message to other other first message is added to DB and then sent to recipient's email. Sometimes SMTP is heavy loaded and it takes up to 5 seconds to get answer from it. I want to enclose SendNewMessageMail(params[]) with async call using other thread or something. I have never done that.

How do i perform this action right in ASP.NET?

View 2 Replies

Wpf - Update UI Async?

Nov 3, 2011

[Code]...

In my scenario the Button_Click is a command delegate in the VM, and the Thread.Sleep is some long-running process (about 2-10 seconds). I want, that when the user calls the command, it should immediately update the UI disabling the button so the user cannot execute it while it's running, then execute that operation, then, when operation completed, unblock the button.

[Code]...

View 3 Replies

Async Callback From ThreadPool?

Jun 12, 2009

I have a bunch of operations that need to be executed simultaneously. For this I'm using the thread pool to execute the tasks. I'd like to know if it's possible to consume some sort of Async Callback (similar to BackgroundWorker.DoWorkComplete) when each thread is finished. The reasoning behind this is that I have a windows service running that uses IPC to update a GUI and I need to know the time at which each specific thread finishes I've used background workers to do a set of tasks and they work perfectly, however, they take longer than I would like. I've timed the execution on my BGW method for a designated number of said tasks and it took 27 seconds, and the same set of tasks takes 4 seconds using the threadpool method. I've also tried using managed threads, to the same effect as the background workers.

View 5 Replies

C# - .NET Async Lambda-expressions?

Apr 20, 2012

Async Sub like this: Dim f As Func(Of Task) = Async Sub() End Sub Produces compiler error: error BC36670: Nested sub does not have a signature that is compatible with delegate 'System.Func(Of System.Threading.Tasks.Task)'.Equivalent C# code compiles fine:

Func<Task> f = async () => { };Rewriting Async Sub into Async Function make code works.

Why does Async Sub() is not convertible to delegate types with return value of type Task?

View 1 Replies

How To Make WebRequest ASync

Oct 1, 2011

I think this is a simple question for you, but I don't understand other cases of webRequests, so I asked here: How can I make this webRequest asynchronous?
Dim sBuffer As String
Dim oRequest As WebRequest = WebRequest.Create(url)
oRequest.Method = "GET"
Dim oResponse As WebResponse = oRequest.GetResponse()
Dim oStream As New StreamReader(oResponse.GetResponseStream())
[Code] .....

View 1 Replies

Using Async CTP Await With Events?

Jul 15, 2011

Relevant to Silverlight 5 / Async CTP

I want to create an asynchronous function that initiates a layout update and then Awaits for the layout update to complete. Something like:

Private Async Function UpdateLayoutRoot() As Task
LayoutRoot.UpdateLayout()
Await LayoutRoot.LayoutUpdated <--- (NOT valid but shows desired outcome)
End Function

How can this be done? More generally, how can you use Await to wait for existing events?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved