PingWorker ClassCleanCode C# Libraries v1.2.03 API
Executes a network ping on a collection of remote servers.
Inheritance Hierarchy

OnlineSystem Object
  CleanCode.Threading ThreadWorker
    CleanCode.Net PingWorker

Namespace: CleanCode.Net
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public class PingWorker : ThreadWorker
Remarks

PingWorker is an implementation of the abstract ThreadWorker class, which performs work in a background thread allowing your foreground GUI to continue interacting with a user. Results are returned via a callback routine that is invoked when you poll for completed items.

See the remarks for ThreadManager for a comprehensive discussion of how to wire up and use ThreadWorkers.

Since CleanCode 0.9.07.

Examples

To use this class you will need to define a callback routine to process results as they become available.
private void MyUpdater(string ip, string msg, IPStatus ipStatus)
{ . . . }
This method is then identified as a delegate to the PingWorker.
PingWorker.PingUpdater pingCallback =
    new PingWorker.PingUpdater(MyUpdater);
Next you instantiate an object with the necessary specifications and tell the ThreadManager about it.
pingWorker = new PingWorker(pingCallback, timeout);
threadManager.Add(pingWorker);
pingWorker.SetIpAddressList(ipList);
threadManager.Run(); // start threads
After you have prepared all of your ThreadWorker objects, you tell the ThreadManager to start them.
threadManager.Run();
pingWorker.UpdateResults();
Finally, you will need to periodically poll for results with this method, which invokes your delegate as needed.
See Also