SendPingAsync makes form freeze

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
jvierra
Posts: 12950
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: SendPingAsync makes form freeze

Post by jvierra » Sun Jul 08, 2018 11:35 am

Great. I actually learned a bit about the newer Net Ping as it now does its own threading and likely uses some good threading tricks. Because I was not familiar with this I decided to build a quick demo. Here is a full demo of a good way to use this in a form.
Attachments
Demo-PingFast.psf
(30.09 KiB) Downloaded 11 times

User avatar
jvierra
Posts: 12950
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: SendPingAsync makes form freeze

Post by jvierra » Sun Jul 08, 2018 3:02 pm

I updated the the demo because I found a bug in my code. It no longer fails intermittently.
Download from the previous post.

User avatar
itbiodk
Posts: 8
Joined: Sun Apr 23, 2017 1:44 pm

Re: SendPingAsync makes form freeze

Post by itbiodk » Tue Jul 10, 2018 6:49 am

Great. I looked through it and it seems akin to what I did. I used the Sapien button - start job control though so your script takes up fewer lines. I think your way could make it more viewable for other people i they decide to edit it at one point.

Thanks.

I finished the tool and the attached images show the result. I might add Round Trip Time as well but I need to examine how precise it is on a single ping.
IpRangePingTool.png:
* A.) IP address that is validated as one types it in. IP address just needs to be within the range you need (Thanks to the Get-IPrange function mentioned earlier).
* B.)Either CIDR or Subnet-mask. If one is validated it fills out the other.
* C.) Only opens up when no errorprovider is active. It is the Button - Start Job control from PS Studio which starts SendPingAsync.
* D.) Can filter the result. I use the DefaultView.RowFilter which is one of the advantages of DataTables. It takes up a single line and it doesn't seem to build the table from the beginning. I did think this would be much faster than building a new result by convertto-datatable $result | where{} but they actually seemed to be pretty equal (didn't time it), however it saves a lot of resources and the wait is only really noticeable at 5000+ entries. It is also very understandable why this happens as I imagine that a standard datatable is not nearly as optimized as a database. There is a lot going on in the background.
2018-07-10_15-21-36.png:
Just shows the error provider that verifies octets are within the allowed range. I have made validations for every wrong entry that I could conceive.
Attachments
2018-07-10_15-21-36.png
2018-07-10_15-21-36.png (18.63 KiB) Viewed 161 times
IpRangePingTool1.png
IpRangePingTool1.png (57.44 KiB) Viewed 161 times

User avatar
jvierra
Posts: 12950
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: SendPingAsync makes form freeze

Post by jvierra » Wed Jul 11, 2018 3:24 pm

Excellent. Looks very easy to use and very useful for large pings.

One note - What you are calling CIDR is really just mask length. A CIDR is a network number plus mask length.

CIDR = 10.0.10.0/24

It is the notation used by classless routing schemes and goes beyond the segment notation. CIDR allows providers to gather disconnected segment into a single net. Mostly this has been made unnecessary by IPv6.

User avatar
itbiodk
Posts: 8
Joined: Sun Apr 23, 2017 1:44 pm

Re: SendPingAsync makes form freeze

Post by itbiodk » Thu Jul 12, 2018 1:54 am

Thank you. I am hoping this can help my colleagues around on other sites as a first step in getting documented everything. We have some large ranges and not everything is documented. This should help by telling what addresses have endpoints to compare to the documentation.
Plus it is fun to make.
I do think I am going to add a button for exporting current output to CSV and/or Excel though. They can copy it from the Data table if they wish, but it is a nice option to have.

In regards to CIDR: Thanks, you are right. I will call it Mask length instead.

Thanks for all your help.

User avatar
jvierra
Posts: 12950
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: SendPingAsync makes form freeze

Post by jvierra » Thu Jul 12, 2018 3:01 am

I don't think anyone will mind if you call it CIDR.

Locked