1
votes

In C# Xamarin iOS I can do this:

InvokeOnMainThread( () => { //do stuff here});

where the argument for InvokeOnMainThread is NSAction

In F# I have

InvokeOnMainThread ( fun _ -> //do stuff here)

but I am getting the error "this expression was expected to have type EventHandler but here has type unit". Why? How can I work around this?

1

1 Answers

3
votes

F# compiler doesn't automatically convert an F# function to NSAction.

You can do it manually though:

InvokeOnMainThread (new NSAction(fun _ -> (* do stuff here *)))