asternet/Asterisk.2013/Asterisk.NET/Manager/ResponseHandlers/TaskResponseHandler.cs
2019-05-17 00:04:13 +03:00

31 lines
799 B
C#

using System.Threading.Tasks;
using AsterNET.Manager.Action;
namespace AsterNET.Manager.Response
{
/// <summary>
///
/// </summary>
public class TaskResponseHandler : IResponseHandler
{
public TaskResponseHandler(ManagerAction action)
{
TaskCompletionSource = new TaskCompletionSource<ManagerResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
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() { }
}
}