Are you looking for a tool that periodically pings a list of hosts? Here is a toolset that will reschedule a ping utilitiy. This ping utility pings a list of hosts and will create notifications if one or most hosts failed to answer.

I have done this toolset with three separate applications. The scheduler and the notification tool are written in C/C++ win32 API cause this API provided the best access to all the possibilities of the used functions. The user notification API is only supported with basic functionality by CF2. The CEUserNotification API is not supported by CF2 at all.

Although OpenNetCF provides an C# interface to the used APIs, I did not like to include all the unneeded stuff. On the other hand the scheduler is fast and small written in C/C++. With C# I had problems with the notification, especially for removing existing notifications and why should the main tool reside in memory just for showing the notification.

The ping tool is written in C# targeting Compact Framework 2. C# was the easiest to implement the GUI.

All source is available thru one Visual Studio 2008 solution. Yes, you can mix C/C++ and CF2 within one solution.

The code of the scheduler called PingAlertScheduler is based on my code How to run an application periodically. The code first clears all existing schedules of themself and then creates a new schedule for xx minutes in the future. If the scheduler is run from the schedule event, it will get a special arg transmitted “PingAlert”

When PingAlertScheduler.exe ist started with “PingAlert” it will also launch the second application of the toolset called PingAlert. The Compact Framework application PingAlert can be started normally to manage the hosts list and it can be started with the argument “pingsweep” and then will automatically start to ping all hosts and then exits itself. If there were ping errors, PingAlert will create a HTML file with a report and then start the notification application of this toolset, which is called PingAlertToast.

How do we handle program arguments in compact framework. See program.cs:

Ah, what is this qData? To have the GUI still responsive during the ping process, the PingAlert uses a queue to add hosts to ping. The background process reads this queue and ping one by the other as long as there are hosts in the queue.

To be able to have some extra information with the hosts I use a class called QueueData which will hold the hosts to ping, the number of ping retries etc.. You can add hosts using there DNS name or there IP address.

How can you you disable the schedule? As you know, PingAlertScheduler can be launched with different args. If it is launched without args, it will create a new schedule and terminates itself. If it is launched with “PingAlert” it will reschedule itself and launch PingAlert with the arg “pingsweep”. If it is launched with the argument “clear”, it will clear all existing schedules to PingAlertScheduler.

So, if you want to stop the scheduling, you have to launch PingAlertScheduler with the argument “clear”. To do so, you can simply use the button “Clear Schedule” in the main PingAlert application.

If you need to start the schedule, you use the button “Schedule”. It will simply launch PingAlertSchedule without an argument.

Now to the last of the trio, PingAlertToast. It is written in C/C++ and creates a user notification. You will get a nice symbol in the taskbar and if you click (tap) it, it will show the notification. This is only a reminder notification signaling that some ping failed.

If you dont like to keep the notification, just tap (Dismiss). To only hide it tap on (Hide). To get the notification back on screen, tap the small symbol in the taskbar.

Within the notification text is a link which should open your internet browser on the device and that shows the report.

The notification API is very strong and enables you to configure nearly everything of the notification. As the API is not fully available in Compact Framework, I did code PingAlertToast in C/C++. Here is the main part creating the notification:

Leave a Reply

Donation/Spenden

This site brings you a lot of information and publishing and hosting costs me time and money. If you appreciate my work and would like to support me and enable me to publish some of the apps in Android Play Store and Windows Phone Store then consider making a donation.
Thank You.