看着:
member this.PostAndReply : (AsyncReplyChannel<'Reply> -> 'Msg) * ?int -> 'Reply
我不明白为什么签名对我来说看起来如此违反直觉。我们要做的是向代理发布消息,然后等待回复。为什么我们必须给他一个奇怪的功能作为“信息”?
再次查看此 MSDN 片段:
let rec loop() =
printf "> "
let input = Console.ReadLine()
printThreadId("Console loop")
let reply = agent.PostAndReply(fun replyChannel -> input, replyChannel)
if (reply <> "Stopping.") then
printfn "Reply: %s" reply
loop()
else
()
loop()
我宁愿喜欢这样的东西:
member this.PostAndReply : 'Msg * ?int -> 'Reply
谢谢