2016-10-19 2 views
1

현재 agxsmpp 프레임 워크를 사용하는 클라이언트 서버 응용 프로그램에서 작업 중이며 로스터 목록이 OnRosterItem 이벤트에 완전히 채워지면 사용자 인터페이스에 명단 목록을 표시하려고합니다. agsxmpp은 비동기 통신을 사용하므로 기능이 완전히 실행될 때까지 기다리지 마십시오. rosterlist가 OnRosterItem 이벤트에 완전히 채워지는 경우 사용자 인터페이스에 RosterList 표시

private void XmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item) 
     { 

      _rosterList.Add(item); 
     } 

사용자 인터페이스 웹 양식 코드

ConnectionManger은 ConnectionManager = (ConnectionManger) 세션 [ "xmppClientConnection"];

do 
    { 
     //wait until rosteritem not yet completed 
     //this is not a good way how can I do this with another approach 
    } while (connectionManager.RosterManager.RosterList.Count == 0); 
    foreach (RosterItem item in connectionManager.RosterManager.RosterList) 
    { 

    }   

답변

1

이 경우 OnRosterStart 및 OnRosterEnd 이벤트를 사용할 수 있습니다.

+0

how ?? 나는 API 레이어와 완이라는 다른 레이어의 모든 이벤트를 사용자 인터페이스의 다른 레이어에 바인딩합니다. 명단리스트가 완료 될 때까지 사용자 인터페이스를 표시하지 않습니까? – bilal

+1

OnRosterStart 이벤트에서 모든 업데이트를 OnRosterStart 이벤트와 OnRosterEnd 이벤트 사이에서 수집 한 다음 UI에 바로 모두 커밋하십시오. 이것이 그 사건들이 존재하는 이유입니다. – Alex