【发布时间】:2020-04-02 00:31:44
【问题描述】:
open System.Reactive.Concurrency
open System.Reactive.Disposables
open System
let print i = printfn "%i on thread %i" i Threading.Thread.CurrentThread.ManagedThreadId
CurrentThreadScheduler.Instance.Schedule((), fun _ _ ->
CurrentThreadScheduler.Instance.Schedule((), fun _ _ -> print 3)
print 2
Disposable.Empty
)
print 1
输出:
2 on thread 1
3 on thread 1
1 on thread 1
为什么print 1 在最外层范围内最后运行?与CurrentThreadScheduler.Instance.Schedule((), fun _ _ -> print 3)不同,为什么前面的语句没有排队并立即执行?
【问题讨论】:
标签: .net f# system.reactive