problem in silverlight 4 async how to wait till result come
Posted
by
AQEEL
on Stack Overflow
See other posts from Stack Overflow
or by AQEEL
Published on 2011-08-28T23:47:58Z
Indexed on
2011/11/25
17:50 UTC
Read the original article
Hit count: 404
Silverlight
|asynchronous
Here is what i have problem
i have following code :
//Get All master record
entryE_QuestMaster = new ObservableCollection<E_QuestMaster>();
QuestVM.getExamsMasterbyExamID(eUtility.ConvertInt32(this.txtID.Text), ref entryE_QuestMaster);
//
//Loop to show questions
int iNumber=1;
foreach (var oIn in entryE_QuestMaster)
{
Node subNode = new Node();
subNode.Content = oIn.e_Question;
subNode.Name = "Quest_" + iNumber.ToString().Trim();
subNode.Tag = oIn.e_QID.ToString();
subNode.Icon = "/Images/Number/" + iNumber.ToString().Trim() + ".gif";
iNumber++;
this.tvMainNode.Nodes.Add(subNode);
}
here is async method calling wcf service
/// <summary>
///
/// </summary>
/// <param name="ID"></param>
public void getExamsMasterbyExamID(int ID, ref ObservableCollection<E_QuestMaster> iCollectionData)
{
ObservableCollection<E_QuestMaster> iCollectionDataResult = iCollectionData;
eLearningDataServiceClient client = new eLearningDataServiceClient();
client.getExamsMasterCompleted+=(s,e)=>
{
iCollectionDataResult = e.Result;
};
client.getExamsMasterAsync(ID);
}
problem : when ever system run --> QuestVM.getExamsMasterbyExamID(eUtility.ConvertInt32(this.txtID.Text), ref entryE_QuestMaster);
its does not wait till i get e.result its just move to next line of code which is foreach loop.
plssss help any one or give idea with sample code what should i do to wait till e.result
i wanted to some how wait till i get e.result
any idea ?
© Stack Overflow or respective owner