<Query Kind="FSharpProgram">
  <Reference>FSharp.Core.dll</Reference>
  <Reference>Hopac.dll</Reference>
  <Reference>Hopac.Core.dll</Reference>
</Query>

open System
open System.Threading
open System.Threading.Tasks

let tid () = Thread.CurrentThread.ManagedThreadId;

open Hopac
open Hopac.Core
open Hopac.Infixes
    
let a = Ch<int> ()
let b = Ch<int> ()
    
let agent1 = 
    let rec loop () = job {
        let! t = Alt.choose [a; b;]
        printfn "[%d] t: %d" (tid()) t
        return! loop ()
        }
        
    start (loop ())
 
let setup = job {
    do! a *<- 10
    do! b *<- 20
    do! b *<- 30
    do! b *<- 40
    do! a *<- 50
    do! a *<- 60
    do! a *<- 70
}

run setup
Console.ReadLine () |> ignore
//