Something like CallLater, but for threading

Just filed a feature request <https://xojo.com/issue/39122>

Basically, the idea is to take the awesome concept introduced with Xojo.Core.Time.CallLater and mirror the mechanism for Xojo.Threading.Thread so we can execute methods in a threaded manner without all the extra setup.

And of course, bring the Xojo.Threading module to the other project types.

Added to my Top Cases. This would really assist with running and managing helper tools. I’m current refactoring old code to use the Task model. This would be one step better.

My feeling is between this request and Timer.CallLater, all improper threading excuses go out the window.

I wrote a class to do this myself in only a few minutes, it’s actually a piece of cake. But built-in convenience features like this are a significant carrot to get people adopting the new framework.

[quote=182650:@Thom McGrath]My feeling is between this request and Timer.CallLater, all improper threading excuses go out the window.

I wrote a class to do this myself in only a few minutes, it’s actually a piece of cake. But built-in convenience features like this are a significant carrot to get people adopting the new framework.[/quote]
Care to share it?

I’ll have to check with my employer, since I wrote it on company time. But it’s dead simple. A thread subclass with two delegates, three properties, two shared methods, and the event handler.

If you look at the Xojo.Core.Timer docs, you can pretty much just mirror the CallLater design.

For now though, you’ll have to fill in the blanks on your own or let another forum member create and share it.

Karen has done it for Timer. She is probably able to give some pointers about how to do it for thread.

I have not looked a threads… but Thom is right… the basic idea is very simple and I had a version of it for timers years ago.

What complicated it a LITTLE bit was to match the Xojo.Core.Timer.CancelCall functionality. In any case my class is open source so anyone can look at the code.

  • Karen

I’ve thought about how to do this but don’t see how to replicate the parameters, ie the target methods parameters would always have to be a single array of Variants or Autos instead of individual typed parameters.

You don’t. Look at the documentation for Xojo.Core.Timer to see how it was done. You have zero or one parameter, that’s it. Yes it’s a bit restrictive, but it is safe, and that is more important. If your method really really needs additional parameters, you can create a class or dictionary to pass in.