Threading examples in Island?

island

(brian71us) #1

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


(JohnMoshakis) #2

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


(marc hoffman) #3

or even just async.


(brian71us) #4

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


(marc hoffman) #5

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


(brian71us) #6

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);


(marc hoffman) #7

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.


(RemObjects) #8

Thanks, logged as bugs://82133


(RemObjects) #9

bugs://82133 got closed with status fixed.