Skip to content

Instantly share code, notes, and snippets.

@johnazariah
Created January 27, 2015 20:25
Show Gist options
  • Save johnazariah/527287a190a14a73b35d to your computer and use it in GitHub Desktop.
Save johnazariah/527287a190a14a73b35d to your computer and use it in GitHub Desktop.
Orleans + F# (async issue)
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