1

Currently, am working on client server application using agxsmpp framework, I want to display the roster list on user interface when roster list gets fully populated on OnRosterItem event . agsxmpp has async communication, do not wait until function fully executes.

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

            _rosterList.Add(item);
        }

user interface webform code

ConnectionManger connectionManager = (ConnectionManger)Session["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)
    {

    }        
bilal
  • 648
  • 8
  • 26

1 Answers1

1

You can use the OnRosterStart and OnRosterEnd events for this.

Alex
  • 4,066
  • 2
  • 19
  • 21
  • how?? I have all the events on different layer called API layer and wan to bind the list on User Interface which is another layer? do not show user interface until roster list is done? – bilal Oct 19 '16 at 11:50
  • 1
    just collect all updates in the OnRosterItem event between the OnRosterStart and OnRosterEnd event and then commit them all at once to your UI. This is the reason why those events are there. – Alex Oct 24 '16 at 19:08