private static TElement EndRunbookAction <TElement>(OrchestratorApi orchestratorApi, IAsyncResult asyncResult)
        {
            QueryOperationResponse <TElement> queryOperationResponse = ActionExtensions.EndExecute <TElement>(orchestratorApi, asyncResult) as QueryOperationResponse <TElement>;

            if (queryOperationResponse == null)
            {
                string message = string.Format("The {0} action did not return the expected response type: QueryOperationResponse<{1}>", new StackFrame(1).GetMethod().Name, typeof(TElement).Name);
                throw new InvalidOperationException(message);
            }
            return(queryOperationResponse.Single <TElement>());
        }