Thread.Run() ignored on windows

Hi,

I have a weird problem here. I have been a decade using the same code on RB but after upgrading to Xojo that code no longer works on Windows. I got no error and no exceptions are thrown, simply the code doesn’t run.

The code is this:

myThread = new my_Thread( parameters here )
If myThread <> nil then myThread.Run()

myThread.Run() never run, I get no nil exception nor no other exception, the object is created but the command myThread.Run() does nothing.

This problem happens on Windows only. It worked fine in RB.
On Mac OS it just works as usual.

Any clue? The code above is inside a method of a SSLSocket object.

Stan

is thread maybe destroyed before it runs?
like do you have a property to keep the thread variable alive?

myThread is created in the SSLSocket object, not in that specific method…

I have tried this:

  Select case myThread.state
  case thread.Running
    Log_Connection( "    ~ Thread State = Running" + EndOfLine, Num )
  case thread.Waiting
    Log_Connection( "    ~ Thread State = Waiting" + EndOfLine, Num )
  case thread.Sleeping
    Log_Connection( "    ~ Thread State = Sleeping" + EndOfLine, Num )
  case thread.Suspended
    Log_Connection( "    ~ Thread State = Suspended" + EndOfLine, Num )
  case thread.NotRunning
    Log_Connection( "    ~ Thread State = Not Running" + EndOfLine, Num )
  end Select
  
  SendMessage.Run()
  
  Select case myThread.state
  case thread.Running
    Log_Connection( "    ~ Thread State = Running" + EndOfLine, Num )
  case thread.Waiting
    Log_Connection( "    ~ Thread State = Waiting" + EndOfLine, Num )
  case thread.Sleeping
    Log_Connection( "    ~ Thread State = Sleeping" + EndOfLine, Num )
  case thread.Suspended
    Log_Connection( "    ~ Thread State = Suspended" + EndOfLine, Num )
  case thread.NotRunning
    Log_Connection( "    ~ Thread State = Not Running" + EndOfLine, Num )
  end Select

On Mac OS I get:

~ Thread State = Not Running
~ Thread State = Running

On Windows I get:

~ Thread State = Not Running
~ Thread State = Not Running

There is definitely something wrong here…

Will this be fixed anytime soon? Really annoying.

Is there a bug report for this?

Yes Joe, <https://xojo.com/issue/32274> with a project to reproduce the issue.

I know this may be an obvious question… but just to make sure, is there a do/loop in the thread that keeps it alive until it gets done processing? If not, the thread may be running once and closing prematurely… causing it to return as not running on the validation (as it already finished). I’ve never had any issues with threads running properly on Windows…

That thread send messages to a SMTP server so it waits until the delivery has been done. The problem is that it not even start.

Is there a reason it has to be done synchronously? You seem to be fighting several async processes here.

[quote=65238:@Stanley Roche Busk]myThread = new my_Thread( parameters here )
If myThread <> nil then myThread.Run()[/quote]

What ‘parameters’ are you putting here? Perhaps it’s not running because myThread is actually nil. Check and be sure…

No, it is no nil. The thread has a constructor.

Actually the code has been working fine for about 10 years on both Mac and Windows. Now it works only on the Mac.
It is a Windows-only failure on Xojo. No Problem with last RealBasic version (previous to first Xojo version).

I have been checking all possible exceptions, nil values…etc… nothing. No error is thrown, the thread simply doesn’t start.

Alright, I apologize for suggesting the obvious… just running through the bases here. The only time this has ever happened to me on Windows (a thread spontaneously closing or failing to run) is when something in the thread itself caused an error, and closed the thread. If I remember right, I didn’t get a notification in the IDE when debugging of the issue. I’ll sift through some old source and see if I can find what caused it and let you know.

Any news on that? I had to downgrade to last RealBasic release to continue development :-/ Xojo is useless for me.

No one has been able to reproduce the issue and the sample doesn’t compile as is

I added some notes but I cannot reproduce it in a sample

if run would actually not work, no web app on Windows would work, so I think it’S working fine.

The sample project is to be built on a Mac and ran on MS Windows. I can compile it here without problems. This problem has forced me to go back to RealBasic, actually the Xojo failure is so BIG I have lost confidence, I have 9 more projects using threads on Windows. I haven’t released anything with Xojo so far. I don’t understand how changing/enhancing an ID can break threads on Windows :-/

Originally I released the defective application to my customer base, I got several hundreds of reports so it is not just me but all my MS Windows clients. I had to downgrade to Realbasic, build again and I saved the situation. No problem here.

So far, for me, Xojo is just for “playing”. After 4 months I am still waiting for a fix :frowning: … what else can I do? Use RealBasic forever?

Christian, Run doesn’t work on that very specific situation, a Mac Xojo build for MS Windows. I am not superficial, there are lots of testing here, I never post something if I am not 100% sure there is a problem. Windows problems are probably getting less attention, they are low priority, Web edition is a black hole that is concentrating all resources, my problem is weird, nobody cares, it only affects me. Each time I post a reminder I get responses like yours. I don’t see any effort in fixing that. My only chances here are making some noise from time to time… :-/

I don’t see a project attached to that report. Did you upload one?

I didn’t see a project, too.

If it’s a problem of cross compiling, well does it really go away when compiling on Windows?
That may point to problems in cross compiling. e.g. with my plugins we had such problems when Mac and Win plugin didn’t have same size of data structures. The compiler would pick size from Mac, built that in windows app and that app would crash.

The project is privately attached