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 261 posts 1177 karma points c-trib
    20 days ago
    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 2943 posts 9276 karma points MVP 3x admin c-trib
    20 days ago
    Dave Woestenborghs
    0

    Hi John,

    I think you can do this ;

    var result= AsyncMethod().Result;
    

    Dave

  • John Churchley 261 posts 1177 karma points c-trib
    6 days ago
    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