I talked about this before, but I can’t find the thread, so I’ll start a new one.
I have discovered that events often don’t happen unless something is updated on a UI window on MacOS. I forgot that and I could not figure out why Events weren’t happening, until I remembered this and added some pointless text writing to the main window.
Other than writing something to the window or using DoEvents, how do I get events to fire (like xxxSocket.ContentReceived). Writing to a window isn’t helpful when the app is opening or closing and shouldn’t be necessary.
Cant say I have ever seen such a thing like needing to update something on a window to make sure events run
they’ve not even part of a window specifically but part of the main event loop which runs regardless as long as the app is running
Lol. How soon you forget! I even showed this to you when I was testing TCPSockets for speed. If I don’t write anything to the screen, the TCPSocket.DataAvailable event stops firing.
Same issue with URLSocket.ContentReceived. Doesn’t fire until something is written to the Main Window. I would assume there are other ways to get it to fire, but the only other one I’ve found is DoEvents, and we know how everyone feels about that!
Well, it’s very difficult to reproduce with 2 Xojo apps. I can’t actually recreate the problem that way.
However, if I send data to and from TCPSockets from an external program (not Xojo) then the problem is easy to see.
The Xojo program just receives data in one socket and sends it out the other.
In this video, I start with the Xojo program merely displaying the # of bytes it receives. If the Xojo program is displaying the # of bytes (updating the UI) then the data flows fine.
Then, I turn off the displaying of the # of bytes, and after a while, the communication slows right down. Merely clicking on the Xojo window (bringing it into focus) and the data starts flowing again. Basically it seems to need SOME kind of UI interaction to keep the TCPSocket events firing.
To do a URLConnection demo, I’d have to create a web page that it sends data to and from, and that’d be a lot more work.
This demo shows the issue.
I’ll post a link to the source, but you’d need external devices sending/receiving TCP data for you to test. I’m using a digital mixer and editor which communicate via TCP.
I had a bunch of stuff in there to try and get 2 Xojo programs to communicate (sending a message or a bunch of numbers from one app to the other) but that doesn’t recreate the problem. So the “Send” and “Send Numbers” and other text fields were for that.
Good call.
It WAS AppNap in this test example that was stopping things.
However, my main software has AppNap disabled (thanks to @npalardy !) but even so, still has issues with URLConnection events not firing unless the UI is being updated.
When I get time I’ll see if I can create a test that uses URLConnection.
Hi Sam;
I have AppNap working well in my main program. I just didn’t in this demo. @npalardy gave me a module that works perfectly to disable AppNap. He’s Da MAN!