ClosestFacility Task
The ClosestFacility task helps you find the closest facilities around any locations (known as incidents) on a network.
When finding closest facilities, you can specify how many to find and whether the direction of travel is toward or away from them. The closest facility solver displays the best routes between incidents and facilities, reports their travel costs, and returns the directions to each facility.

The classes involved in solving closest facility operations include ClosestFacilityParameters, ClosestFacilityTask, and ClosestFacilitySolveResults:

ClosestFacillityParameters includes input parameters such as the default cutoff, whether or not to return incidents, routes, directions, and more. These parameters are used as input to the ClosestFacilityTask which contains a solve() method. Finally, results are passed from ArcGIS Server back to the client in the form of a ClosestFacilitySolveResults object.
The ClosestFacilityParameters object is used as input to ClosestFacilityTask...