Subclassed Timer Calling Delegate.Invoke Causes Segmentation Fault on Raspberry Pi

Hello everyone, once again this raspberry project has me backed into a corner around a bug I have found. Just wondering if anyone else has come across this or has found a way around it?

<https://xojo.com/issue/58312>

Thanks again,
Alex

I see the case was closed as “not a bug”. Did you ever resolve this yourself? If not, would you mind sharing a snippet of your code where you create the timer, AddHandler, etc.? Love to help if I can.

It appears that this only happens on console, must have to do with the way the event loop is implemented. I think I posted an example project in the feedback case, it is mostly when calling an method from CustomTimer.Run via Delegate.Invoke. I haven’t found a way around it other then just making a bunch of timers as app properties and only use AddHandler.

Hope this helps you, it would be great to get this fixed at some point.

i think it has more to do with it being an instance method based on @William Yu 's comment

however, since you could use addhandler with an instance method I will confess I dont see why this specific usage should be problematic since addhandler also uses a delegate
and the sample on the case doesnt cause an exception on macOS so there’s “something” special about why this behaves this way on a Pi that remains unknown to the rest of us

[quote=466195:@Norman Palardy]i think it has more to do with it being an instance method based on @William Yu 's comment

however, since you could use addhandler with an instance method I will confess I dont see why this specific usage should be problematic since addhandler also uses a delegate
and the sample on the case doesnt cause an exception on macOS so there’s “something” special about why this behaves this way on a Pi that remains unknown to the rest of us[/quote]

There is quite a few of these odd ball things I have found on Linux, especially the raspberry pi. I assume it has to do the fact it is a new xojo build platform and not all the bugs have been ironed out.

It would appear that timer calls from instances to delegate methods execute with the context of the instance and not of the delegate parent. When I could get it to work it would not have access to the delegate parents properties.

No idea but this example on this case works perfectly fine on macOS
Which suggests to me its a bug

[quote=466209:@Norman Palardy]No idea but this example on this case works perfectly fine on macOS
Which suggests to me its a bug[/quote]

My thoughts exactly, I would expect this to work the same on Linux as it does Mac and desktop apps.

Creating a subclass of a timer would really help my code structure, I need quite a few timers because Thread.Sleep and App.DoEvents both cause 100% cpu on raspberry pi.

did you try a shared method on the App instance instead of the instance method
there are some gotchas to that but it would be interesting to know if this worked

[quote=466213:@Norman Palardy]did you try a shared method on the App instance instead of the instance method
there are some gotchas to that but it would be interesting to know if this worked[/quote]

I will have to get back to my raspberry and give it a try, thanks!