Threading examples in Island?

Hello,

Do you have any examples of threading in Island? Just something simple for handling background tasks in a non-platform specific way?

Thank you,
Brian Wheatley

I think you want to use Task

  var t := Task<String>.Run(method begin
    
    exit 'helloworld';
  end);
  
  Console.WriteLine($"Result is {t.Result}");

I know it exists on the windows sub platform and I’ve used it in Toffee.

Cheers,
John

or even just async.

I’m getting an error that there is no static member Run…

there isn’t, i believe. https://docs.elementscompiler.com/API/IslandRTL/Classes/Task/

OK there must be more than one “Task” type because RemObjects.Elements.MicroTasks.Task doesn’t have a Run method but if I put the code in as John showed it works.

Task client = Task.Run(GetData);

You’ll want RemObjects.Elements.System.Task, actually. That one should be in scope by default (MicroTasks.Task isn’t), and has a static Run method, actually.

I’ll bring up to consider renaming the other one, to avoid confusion.

Thanks, logged as bugs://82133

bugs://82133 got closed with status fixed.