Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : HbPLL5DNAbMB9B/OeXUmtk
Finance | Project Operations, Human Resources, ...
Answered

Task.result takes more time for assigning to a Str variable in X++

Like (3) ShareShare
ReportReport
Posted on 5 Mar 2025 23:08:33 by 100
Hi All,
 
I am calling an external webservice from D365FO using a C# class. this class dll I used it as a reference in my D365FO project.
 
the C# class is returning an Async task<String> 
 
from my X++ code I am able to get the result by using the code below
 
var task = referenceClass.Method(....);
 
Str result = task.result;
 
this particular line mentioned above is a performance killer. this is making my class execution longer than before.
 
Is there any alternative way to get the string value faster from the task ?
 
Thanks in advance for the help.
 
 
Categories:
  • Martin Dráb Profile Picture
    231,831 Most Valuable Professional on 17 Mar 2025 at 18:56:09
    Task.result takes more time for assigning to a Str variable in X++
    Hmm, what do you mean by "code to deal this"?
     
    If you need the result of the task ASAP, you must wait for the task to complete and produce the result. You can't use the result before it's produced - that would require time travelling. :)
     
    Maybe you don't need to wait for the result; you may want to add another task running on completion.
     
    Or maybe you don't need the result at all; then you shouldn't try to get it. 
  • rama.krishna.tanneeru@munich-airport.de Profile Picture
    100 on 17 Mar 2025 at 15:36:09
    Task.result takes more time for assigning to a Str variable in X++
    @Martin Dráb: if possible could you please let me know a sample code to deal this. the earlier fix "task.result" was copied from one of your blogs. thanks a lot for that post. 
  • Verified answer
    Martin Dráb Profile Picture
    231,831 Most Valuable Professional on 06 Mar 2025 at 05:59:01
    Task.result takes more time for assigning to a Str variable in X++
    Accessing the Result property causes waiting for the completion of the asynchronous method. Yes, skipping the method is faster than executing it and waiting for it compleing the work, but you can't get the result in such a case, because no result exist at the moment.
     
    If you want to make it faster, you need to look at what the asynchronous method does and try to optimize it.
     
    Note that this is nothing specific to F&O. You may want to learn about asynchronous methods and Task Parallel Library in .NET before continuing.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,997 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,831 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading started