-
-
Save johnazariah/527287a190a14a73b35d to your computer and use it in GitHub Desktop.
Orleans + F# (async issue)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SyncXeroPrivateApplicationGrain() = | |
inherit GrainBase() | |
interface ISyncXeroPrivateApplicationGrain with | |
member this.SynchronizeAsync() = | |
let orleansTaskScheduler = TaskScheduler.Current | |
async { | |
let companyFile = XeroCompanyFile () | |
let guid = | |
match companyFile.CompanyFileIdentifier with | |
| CompanyFileIdentifier _guid -> _guid | |
let uri = companyFile |> saveCompanyFile companyFile.CompanyFileIdentifier | |
//Filthy hack to get the code to run on the orleans task scheduler | |
do! Task.Factory.StartNew((fun () -> | |
let plotGrain = GenerateAccountBalanceCsvGrainFactory.GetGrain(0L) | |
plotGrain.GenerateCsvAsync(guid)), CancellationToken.None, TaskCreationOptions.None, orleansTaskScheduler).Unwrap() | |
|> Async.AwaitTask |> Async.Ignore | |
return uri | |
} | |
|> Async.StartAsTask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the code above, there really shouldn't be a Task.Factory.StartNew inside the async {}; what is desired is the ability to just 'do! plotGrain.Generate...' to asynchronously call the plotGrain grain's method!