在F#中,谁泵送消息队列? [英] In F#, who pumps the message queue?
问题描述
在F#中,如果我做类似的事情 let form = new Form(Text ="MyForm") 并在FSI中运行它,该表单将正常显示和更新,甚至接收消息.但是,谁在泵送消息队列?这里没有Application.Run调用.我有点困惑.
In F# if I do something like let form = new Form(Text = "MyForm") and run it in FSI, the form will display and update normally, and even recieve messages. However, who is pumping the message queue? There is no Application.Run call here. I'm a little confused.
推荐答案
正如ildjarn所说,F#Interactive实现了自己的消息循环.有趣的是,消息循环未在F#Interactive中进行硬编码,因此您可以对其进行更改.这是非常有用的,因为默认的是基于Windows窗体的,但是您可能还要使用其他GUI框架.
As ildjarn says, F# Interactive implements its own message loop. Interestingly, the message loop is not hardcoded in F# Interactive, so you can change it. This is quite useful, because the default one is based on Windows Forms, but there are other GUI frameworks you may want to use.
为此,您需要实现IEventLoop
接口,然后将实例分配给fsi.EventLoop
属性.有关更多信息,请参见:
To do that, you would need to implement IEventLoop
interface and then assign your instance to the fsi.EventLoop
property. For more information see:
- The source code for
IEventLoop
interface - The default implementation that uses WinForms
- A simple implementation that I wrote for Gtk#
这篇关于在F#中,谁泵送消息队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!