开发者

In F#, who pumps the message queue?

开发者 https://www.devze.com 2023-02-17 00:11 出处:网络
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?

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 Applic开发者_运维技巧ation.Run call here. I'm a little confused.


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.

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#


FSI has its own message pump for this very reason.

0

精彩评论

暂无评论...
验证码 换一张
取 消