Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John Churchley 272 posts 1258 karma points c-trib
    Aug 30, 2018 @ 11:06
    John Churchley
    0

    Async Methods TreeController

    I'm need to call an async method which calls an external API inorder to obtain the data for tree.

    TreeController requires the following method

    protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)

    How do I get around the method is synchronous return type?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Aug 30, 2018 @ 12:02
    Dave Woestenborghs
    0

    Hi John,

    I think you can do this ;

    var result= AsyncMethod().Result;
    

    Dave

  • John Churchley 272 posts 1258 karma points c-trib
    Sep 13, 2018 @ 13:31
    John Churchley
    100

    Thanks Dave,

    Really close I end up doing

    var result = Task.Run(() => method()).Result;
    
Please Sign in or register to post replies

Write your reply to:

Draft