I have the following code in a C# lib
public class A
{
public async Task CreateEntity(Model m) {
/* no return here but await for db insert and set m.Id */
}
}
I have another application in F# that references this lib and try to call CreateEntity. I would like to be able to do await on it but I can not find any examples of this .
How to block or 'await' in my F# app? It seems that there is an issue with the fact that the return value is not Task<T>
UPDATE
Could someone make this one work correctly
I have been able to reproduce the issue with the following snippet
open System.Threading.Tasks
let awaitTask = Async.AwaitIAsyncResult >> Async.Ignore
printfn "Before"
awaitTask(Task.Delay 10000)
printfn "After"
It returns in less than a sec, so it does not await
I have indeed seen that this question is related to another post. But as none of the answers seem to work, I have asked it again. If someone could provide a complete F# snippet that work that would definitely help me a lot.