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.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: SendPingAsync makes form freeze

Post by jvierra »

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 95 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: SendPingAsync makes form freeze

Post by jvierra »

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
Last visit: Thu Oct 26, 2023 7:59 am

Re: SendPingAsync makes form freeze

Post by itbiodk »

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 1449 times
IpRangePingTool1.png
IpRangePingTool1.png (57.44 KiB) Viewed 1449 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: SendPingAsync makes form freeze

Post by jvierra »

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
Last visit: Thu Oct 26, 2023 7:59 am

Re: SendPingAsync makes form freeze

Post by itbiodk »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: SendPingAsync makes form freeze

Post by jvierra »

I don't think anyone will mind if you call it CIDR.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked