locked
async callback in Silverlight client RRS feed

  • Question

  • Hello,

    In the Silverlight client screen _Created method, I want to hit a web api to perform some data operations on the server (i.e. commanding).  No problem there.  Question: Once the operations are complete on the server, how can I get a callback to refresh the SL client screen.  I want this to happen asynchronously so that I don't block the ui while the operation is underway.  TIA

    Wednesday, November 5, 2014 3:24 PM

All replies

  • Hi!

    Didn't play with this myself, but recently was searching some things on Paul van Bladel's blog and there you have some examples of async stuff.. 

    check http://blog.pragmaswitch.com/?tag=async , maybe it helps..

    Kivito


    Nobody expects the Spanish Inquisition! (M.P.F.C.)

    Wednesday, November 5, 2014 3:33 PM
  • Kivito,

    Thanks for that.  I will check it out.

    Wednesday, November 5, 2014 4:07 PM
  • The Async section of Paul Van Bladel's blog is very helpful.  However, I am still not sure how to get a call back from web api.  Does anyone know how to accomplish this in the Sliverlight client?  Thanks.
    Thursday, November 6, 2014 1:30 PM
  • Hi Hessc,

    >>Question: Once the operations are complete on the server, how can I get a callback to refresh the SL client screen.

    API support for refreshing data on lists and screens in the runtime app, please check whether it helps you.

    refresh()      
    • Asynchronously loads the first page of items into this collection and           
      returns a promise that will be fulfilled when the first page is loaded.            
    refresh(navigationPropertyNames)      
    • Updates the entity with values from the data source if the entity           
      is not changed.

    See: New API For Refreshing Data in LightSwitch in Visual Studio 2013 

    Please let me know if there is anything that I can do to help.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 19, 2014 7:29 AM
  • See: https://code.msdn.microsoft.com/vstudio/Simple-web-api-based-file-5e0c5844/sourcecode?fileId=96705&pathId=1513641315

    paul.


    paul van bladel ==independent enterprise application architect== http://blog.pragmaswitch.com

    Wednesday, November 19, 2014 10:46 AM
  • Thanks Paul.  Lots of great stuff in that sample.
    Friday, November 21, 2014 6:17 AM
  • Could you find specifically what you were looking for?

    paul van bladel ==independent enterprise application architect== http://blog.pragmaswitch.com

    Friday, November 21, 2014 8:32 AM
  • Paul,

    I did not see a callback from asynchronous code in the sample.  It may be there but I have not gone through all of it yet.  Nevertheless, there are lots of other things in there that will be helpful.  What I am trying to do is perform some operations after LS sends emails from an async method. 

    // simplified version private static async Task SendAsync(MailMessage message) { using (SmtpClient client = new SmtpClient("somemailhub.com", 25)) { client.UseDefaultCredentials = true; try { await client.SendMailAsync(message); // how to get the callback?

    // do stuff here } catch (Exception) // Make this specific { throw; } } }

    This code works fine, I just want to do some logging so I can record whether or not the message was successfully delivered and that sort of thing.


    • Edited by Hessc Friday, November 21, 2014 9:00 PM
    Friday, November 21, 2014 8:58 PM
  • I just realized that the async callback on the server in my last post is not the same issue I originally posted about -- sorry for that.  In the OP, I am looking for a way to await a task initiated on the client.  I am still in need of that.  In my last post, I am looking for the way to get the callback so I can do something with the results. 
    Friday, November 21, 2014 9:12 PM