using System; namespace Cryville.Common { /// /// Represents a cancellable asynchronized task. /// /// public class AsyncDelivery { /// /// The delegate to cancel the task. /// public Action CancelSource { private get; set; } /// /// The delegate to call on task completion. /// public Action Destination { private get; set; } /// /// Delivers the result to the destination. /// /// Whether the task has succeeded. /// The result. public void Deliver(bool succeeded, T result) { Destination?.Invoke(succeeded, result); } /// /// Cancels the task. /// public void Cancel() { CancelSource?.Invoke(); } } }