Created
February 24, 2012 10:27
-
-
Save schuster-rainer/1900009 to your computer and use it in GitHub Desktop.
Script to reference GTK# assemblies and create an fsi event loop for dispatching the commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Script from Tomas Petricek | |
// http://stackoverflow.com/questions/4174852/how-to-force-f-interactive-to-reference-gtk-by-default | |
[<AutoOpen>] | |
module GtkSharp | |
// Load some common Gtk# assemblies (from /usr/lib/mono/2.0/../gtk-sharp-2.0) | |
#r "../gtk-sharp-2.0/gtk-sharp.dll" | |
#r "../gtk-sharp-2.0/gdk-sharp.dll" | |
#r "../gtk-sharp-2.0/glib-sharp.dll" | |
#r "../gtk-sharp-2.0/atk-sharp.dll" | |
open Gtk | |
Application.Init() | |
fsi.EventLoop <- | |
{ new Microsoft.FSharp.Compiler.Interactive.IEventLoop with | |
member x.Run() = Application.Run() |> ignore; false | |
member x.Invoke f = | |
let res = ref None | |
let evt = new System.Threading.AutoResetEvent(false) | |
Application.Invoke(new System.EventHandler(fun _ _ -> | |
res := Some(f()) | |
evt.Set() |> ignore )) | |
evt.WaitOne() |> ignore | |
res.Value.Value | |
member x.ScheduleRestart() = () } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment