2018-08-29 22:56:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using AsterNET.Manager.Action;
|
|
|
|
|
|
|
|
|
|
namespace AsterNET.Manager.Response
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TaskResponseHandler : IResponseHandler
|
|
|
|
|
{
|
|
|
|
|
public TaskResponseHandler(ManagerAction action)
|
|
|
|
|
{
|
2019-03-25 20:05:12 +00:00
|
|
|
|
TaskCompletionSource = new TaskCompletionSource<ManagerResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
|
2018-08-29 22:56:26 +00:00
|
|
|
|
Action = action;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TaskCompletionSource<ManagerResponse> TaskCompletionSource { get; }
|
|
|
|
|
|
|
|
|
|
public ManagerAction Action { get; }
|
|
|
|
|
|
|
|
|
|
public int Hash { get; set; }
|
|
|
|
|
|
|
|
|
|
public void HandleResponse(ManagerResponse response)
|
|
|
|
|
{
|
|
|
|
|
TaskCompletionSource.TrySetResult(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Free() { }
|
|
|
|
|
}
|
|
|
|
|
}
|