window.showModal blocks Socket

It seems that under cocoa if I have a modal window open (opened with .showmodal) and I have an open easyTCPsocket that is listening, its receivedMessage event will not fire until the window is closed.

Is this a bug or correct behavior?

Thanks,
Jim

ShowModal stops all running code until the modal is closed.

[quote=199058:@James Meyer]It seems that under cocoa if I have a modal window open (opened with .showmodal) and I have an open easyTCPsocket that is listening, its receivedMessage event will not fire until the window is closed.

Is this a bug or correct behavior?[/quote]

From what I see, showmodal does not stop a Thread, so that may be the solution for your listening socket.

… and the Thread cannot update the UI… so I need to work around that… Seems like a lot of screwing around for something that should be simple.

Offhand it sounds like a bug.

It is simply never that simple :wink:

You may want to try and see if TCPSocket has the same issue.

Another way would be to add a secondary easyTCPSocket on the modal to do the listening.

Or wait for the bug to be fixed, in a few months…

I will try to replicate in a small project and report it…

More info: My situation is basically this: I have a .showModal window open… it includes a button that when clicked executes a easyTCPSocket.SendMessage()… that message is received by another app which in turn sends another message back.

After some more testing it appears that my problem is that the easyTCPSocket.SendMessage() does not actually send the message until the .showModal window is dismissed. If I simply .show the window instead of .showModal the message is sent and the reply is received OK.

Is this expected behavior? Should .showModal block the socket from sending?

Thanks

Yes, but not because it should – code execution stops until the window is hidden or closed. So if the SendMessage command is placed after ShowModal it will of course not be called prior to the closing of the window. I would override ShowModal and call SendMessage in there followed by Super.ShowModal.

[quote=199169:@James Meyer]I have a .showModal window open… it includes a button that when clicked executes a easyTCPSocket.SendMessage()… that message is received by another app which in turn sends another message back.

After some more testing it appears that my problem is that the easyTCPSocket.SendMessage() does not actually send the message until the .showModal window is dismissed. If I simply .show the window instead of .showModal the message is sent and the reply is received OK.

Is this expected behavior? Should .showModal block the socket from sending?[/quote]

If the socket on the modal window ? If it is, it should work.