Windows fatal exception: access violation

Hi Andrea,

In your code, I fixed L103 as follows:

-            wx.CallAfter(self.DoLongRunningTask, i)
+            self.DoLongRunningTask(i)

Then, everything works fine.

I’m using wxPython 4.2.1, Python 3.11.4.
The matplotlib version should be 3.7.2 ~ 3.8.0/WXAgg recently released, where a wx-event-related bug fix has been applied: https://github.com/matplotlib/matplotlib/pull/25559.

Thank you for your answer. The issue is, the matplotlib rendering has to happen in the main thread - not in a separate one. That’s why I used wx.CallAfter.

The code I posted is a huge simplification of what we actually have in our application. That said, it is my understanding that flush_events() invokes wx.Yield(), which should not be run in a different thread other than the main thread.

I’m not entirely sure what canvas.restore_region() and blit() in matplotlib do, but if they invoke wx functions/methods they have to be run in the main thread.

My dear sir, every big, hiccup, whatchamacallit, thingamajig, event… Has somehow somewhere seemed to be documented by you before. Don’t take me as a precedent, but stranger things have occured… Your documentation methods seem flawless, tho I am sometimes stuck at your commenting… Please work on that stuff…