DataServiceContext.BeginExecute 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
특정 URI를 실행하기 위해 데이터 서비스에 요청을 비동기적으로 보냅니다.
오버로드
| Name | Description |
|---|---|
| BeginExecute<T>(DataServiceQueryContinuation<T>, AsyncCallback, Object) |
페이징된 쿼리 결과에서 데이터의 다음 페이지를 검색하기 위해 데이터 서비스에 요청을 비동기적으로 보냅니다. |
| BeginExecute<TElement>(Uri, AsyncCallback, Object) |
서비스의 결과를 기다리는 동안 이 호출이 처리를 차단하지 않도록 요청을 비동기적으로 보냅니다. |
BeginExecute<T>(DataServiceQueryContinuation<T>, AsyncCallback, Object)
페이징된 쿼리 결과에서 데이터의 다음 페이지를 검색하기 위해 데이터 서비스에 요청을 비동기적으로 보냅니다.
public:
generic <typename T>
IAsyncResult ^ BeginExecute(System::Data::Services::Client::DataServiceQueryContinuation<T> ^ continuation, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginExecute<T>(System.Data.Services.Client.DataServiceQueryContinuation<T> continuation, AsyncCallback callback, object state);
member this.BeginExecute : System.Data.Services.Client.DataServiceQueryContinuation<'T> * AsyncCallback * obj -> IAsyncResult
Public Function BeginExecute(Of T) (continuation As DataServiceQueryContinuation(Of T), callback As AsyncCallback, state As Object) As IAsyncResult
형식 매개 변수
- T
쿼리에서 반환되는 형식입니다.
매개 변수
- continuation
- DataServiceQueryContinuation<T>
DataServiceQueryContinuation<T> 데이터 서비스에서 반환할 데이터의 다음 페이지를 나타내는 개체입니다.
- callback
- AsyncCallback
클라이언트 사용 시 결과를 사용할 수 있는 경우 호출할 대리자입니다.
- state
- Object
콜백에 전달된 사용자 정의 상태 개체입니다.
반품
IAsyncResult 작업의 상태를 나타내는 값입니다.
설명
제공된 DataServiceQueryContinuation<T> 개체에는 실행될 때 쿼리 결과에 있는 데이터의 다음 페이지를 반환하는 URI가 포함됩니다.
적용 대상
BeginExecute<TElement>(Uri, AsyncCallback, Object)
서비스의 결과를 기다리는 동안 이 호출이 처리를 차단하지 않도록 요청을 비동기적으로 보냅니다.
public:
generic <typename TElement>
IAsyncResult ^ BeginExecute(Uri ^ requestUri, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginExecute<TElement>(Uri requestUri, AsyncCallback callback, object state);
member this.BeginExecute : Uri * AsyncCallback * obj -> IAsyncResult
Public Function BeginExecute(Of TElement) (requestUri As Uri, callback As AsyncCallback, state As Object) As IAsyncResult
형식 매개 변수
- TElement
쿼리에서 반환되는 형식입니다.
매개 변수
- requestUri
- Uri
쿼리 요청을 보낼 URI입니다. URI는 유효한 데이터 서비스 URI일 수 있습니다. 쿼리 매개 변수를 포함 $ 할 수 있습니다.
- callback
- AsyncCallback
클라이언트 사용 시 결과를 사용할 수 있는 경우 호출할 대리자입니다.
- state
- Object
콜백에 전달된 사용자 정의 상태 개체입니다.
반품
비동기 작업의 상태를 추적하는 데 사용되는 개체입니다.
예제
다음 예제에서는 메서드를 호출하여 쿼리를 시작하여 비동기 쿼리를 BeginExecute 실행하는 방법을 보여줍니다. 인라인 대리자는 메서드를 EndExecute 호출하여 쿼리 결과를 표시합니다. 이 예제에서는 WCF Data Services를 완료할 때 만들어지는 Northwind 데이터 서비스를 기반으로 서비스 참조 추가 도구에서 생성한 것을 사용합니다 DataServiceContext .
public static void BeginExecuteCustomersQuery()
{
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
// Define the query to execute asynchronously that returns
// all customers with their respective orders.
DataServiceQuery<Customer> query = (DataServiceQuery<Customer>)(from cust in context.Customers.Expand("Orders")
where cust.CustomerID == "ALFKI"
select cust);
try
{
// Begin query execution, supplying a method to handle the response
// and the original query object to maintain state in the callback.
query.BeginExecute(OnCustomersQueryComplete, query);
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}
}
// Handle the query callback.
private static void OnCustomersQueryComplete(IAsyncResult result)
{
// Get the original query from the result.
DataServiceQuery<Customer> query =
result as DataServiceQuery<Customer>;
foreach (Customer customer in query.EndExecute(result))
{
Console.WriteLine("Customer Name: {0}", customer.CompanyName);
foreach (Order order in customer.Orders)
{
Console.WriteLine("Order #: {0} - Freight $: {1}",
order.OrderID, order.Freight);
}
}
}
Public Shared Sub BeginExecuteCustomersQuery()
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
' Define the delegate to callback into the process
Dim callback As AsyncCallback = AddressOf OnCustomersQueryComplete
' Define the query to execute asynchronously that returns
' all customers with their respective orders.
Dim query As DataServiceQuery(Of Customer) =
context.Customers.Expand("Orders")
Try
' Begin query execution, supplying a method to handle the response
' and the original query object to maintain state in the callback.
query.BeginExecute(callback, query)
Catch ex As DataServiceQueryException
Throw New ApplicationException(
"An error occurred during query execution.", ex)
End Try
End Sub
' Handle the query callback.
Private Shared Sub OnCustomersQueryComplete(ByVal result As IAsyncResult)
' Get the original query from the result.
Dim query As DataServiceQuery(Of Customer) =
CType(result.AsyncState, DataServiceQuery(Of Customer))
' Complete the query execution.
For Each customer As Customer In query.EndExecute(result)
Console.WriteLine("Customer Name: {0}", customer.CompanyName)
For Each order As Order In customer.Orders
Console.WriteLine("Order #: {0} - Freight $: {1}",
order.OrderID, order.Freight)
Next
Next
End Sub
설명
반환 IAsyncResult 된 개체는 비동기 작업이 완료된 시기를 결정하는 데 사용됩니다. 자세한 내용은 비동기 작업을 참조하세요.
이 메서드 BeginExecute 는 동일한 의미 체계를 Execute사용하지만 이 메서드는 서비스의 결과를 기다리는 동안 이 호출이 처리를 차단하지 않도록 요청을 비동기적으로 보냅니다. 표준 시작-끝 비동기 패턴에 따라 제공된 콜백은 쿼리 결과를 검색할 때 호출됩니다.