2016-10-19 7 views
1

現在、agxsmppフレームワークを使用してクライアントサーバーアプリケーションで作業しています。 agsxmppは非同期通信を持ち、機能が完全に実行されるまで待たないでください。rosterlistがOnRosterItemイベントで完全に設定されたときにユーザーインターフェイスに表示する

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レイヤとWanと呼ばれる別のレイヤ上のすべてのイベントを持っていますか?リストの登録が完了するまでユーザーインターフェイスを表示しないでください。 – bilal

+1

OnRosterStemイベントのすべての更新をOnRosterStartイベントとOnRosterEndイベントの間で収集し、それらを一度にUIにコミットするだけです。これが、これらのイベントが存在する理由です。 – Alex

関連する問題