Is there any way to call some DotNet async method from C/AL synchronously?
In C# it can be done like this:
Method definition:
public async Task<string> GetDataAsync(string parameter){}
Synchronous call:
string result = somObject.GetDataAsync(parameter).Result;
Unfortunately I can't translate this to C/AL. Property "Result" is not available, and without this part method is called asynchronously. Somehow I need to call this method synchronously, wait until it finishes and grab the result.
Answers
The AL language does not support async .Net operations. If you must use an async function, you have to encapsulate it in a wrapper that hides the async behavior.
Niels-Henrik Sejthen
Senior Software Developer
Microsoft Dynamics NAV
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
Or if you really want to, check if you can access it using reflection? But I'm not sure that would work.
Checking one of our projects, I can see we have used the Result property on asyncrhonous method calls successfully, like this:
B3 Technologies - Making Technology Serve the People