windows phone 8 - Append contacts in contact list in WP8 -



windows phone 8 - Append contacts in contact list in WP8 -

i want add together more 1 contacts contact list xml file, savecontacttask.show(); added 1 contact contact list, please tell me how resolve issue .

this code:

private void addcontacts(object sender, routedeventargs e) {

using (isolatedstoragefile istf = isolatedstoragefile.getuserstoreforapplication()) { using (isolatedstoragefilestream istfs = istf.openfile("mycontacts.xml",filemode.open)) { xdocument doc = xdocument.load(istfs); var query = d in doc.root.descendants("contacts") select new { firstname = d.element("name").value, mobilephone = d.element("phone").value }; foreach (var po in query) { savecontacttask.firstname = po.firstname; savecontacttask.mobilephone = po.mobilephone; savecontacttask.show(); } } }

savecontacttask class designed add together 1 contact @ time , show() function asynchronous. can't add together sec contact until first phone call finished. code should rewritten react on savecontacttask.completed += new eventhandler<savecontactresult>(savecontacttask_completed); event , start adding second(etc) contact when previous finished. there possibility, new savecontacttask should used second(etc) contact, bear in mind.

try (it's sample of idea):

private list<contact> listtoadd; private savecontacttask savetask; savetask.completed += addcomplete; void addcomplete(...) { if ( listtoadd.count > 0 ) { contact contact = listtoadd[0]; listtoadd.removeat(0); savetask. (set values contact) savetask.show(); } }

windows-phone-8

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -