0

나는 그것은 여기 MSDN에 규정 된 방식으로 설정 RIA 서비스로 설정하는 응용 프로그램, 엔티티 프레임 워크 4, 실버 라이트 4있어 : 클라이언트 측에 Walkthrough: Creating a RIA Services Solution비동기 RIA 서비스 호출에서 알림을 얻으려면 어떻게해야합니까?

을,이 코드는 고객 엔티티를로드 그리드의 ItemsSource로 :

public MainPage() 
    { 
     InitializeComponent(); 

     LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery()); 
     CustomerGrid.ItemsSource = loadOp.Entities; 
    } 

"loadOp.Entities는"(RIA 서비스에 의해 자동으로) 비동기 적으로 수행 할 수있는 전화. 비동기 호출이 완료되면 어떻게 알림을 받습니까?

답변

2

콜백을 사용해야합니다. 아직 RIA의 공식 릴리스를 사용하지는 않았지만 베타 버전에서는 그렇게 사용되었습니다.

public MainPage() 
{ 
    InitializeComponent(); 

    LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery(),MyCallback,null); 
    CustomerGrid.ItemsSource = loadOp.Entities; 
} 

private void MyCallback(LoadOperation<Customer> loadOperation) 
{ 
    //This will be called when the load is complete 
} 
+1

감사합니다. 출시 된 RIA Services 버전에서는로드에 필요한 추가 인수가 있습니다 (예 : this._customerContext.Load (this._customerContext.GetCustomersQuery(), MyCallback, null); – sparks

+0

예'objectState' 인수를 잊어 버렸습니다. 이는 .NET에서 비동기 호출에 대한 꽤 일반적인 인수입니다. – Stephan