So you are STARTing two threads from a procedure with a window which has an Accept() loop?
If Yes, the Clarion docs suggest this would work for starting two procedures.
IF MyConditionToStartTwoThreads = True
If Loc:LastStartProc <= 0 OR Loc:LastStartProc = 2
Loc:ProcAThreadID = Start(MyProcA,50000,MyCsvParamString) !Loc:ProcAThreadID is if you need the thread id.
Loc:LastStartProc = 1
Cycle !This then lets the accept loop and RTL do its stuff to resume Loc:ProcAThreadID
End
If Loc:LastStartProc = 1
Loc:ProcBThreadID = Start(MyProcB,50000,MyCsvParamString)
Loc:LastStartProc = 2
MyConditionToStartTwoThreads = False
Cycle !This then lets the accept loop and RTL do its stuff to resume Loc:ProcBThreadID
End
End !IF MyConditionToStartTwoThreads = True
Technically this is an alternative way to write the code but this example will increase your chances of lockups.
Loc:ProcAThreadID = Start(MyProcA,50000,MyCsvParamString)
Resume(Loc:ProcAThreadID)
Yield !Useful only if the MyProcA has no window as it hands back to Windows but doesnt help the Clarion RTL when a Window needs to be opened.
Loc:ProcBThreadID = Start(MyProcB,50000,MyCsvParamString)
Resume(Loc:ProcBThreadID)
Yield !Useful only if the MyProcB has no window as it hands back to Windows but doesnt help the Clarion RTL when a Window needs to be opened.
If the Loc:ProcAThreadID and Loc:ProcBThreadID is not required, technically the code can be shortened to
Resume(Start(MyProcA,50000,MyCsvParamString))
Yield !Useful only if the MyProcA has no window as it hands back to Windows but doesnt help the Clarion RTL when a Window needs to be opened.
Resume(Start(MyProcB,50000,MyCsvParamString))
Yield !Useful only if the MyProcB has no window as it hands back to Windows but doesnt help the Clarion RTL when a Window needs to be opened.
but this example code can also cause lockups.
The point is, you need the calling parent window to cycle through its Accept loop to resume the 1st or 2nd thread, in order for the Clarion runtime to be “happy” and lets Windows have some time to do its stuff in order to minimise lockups.
Its like @mark_sarson says, lockups can occur when starting too many threads too quickly, and this problem is also machine dependent because each machine can have fast or slow hardware and different apps running, so you might see this problem on low spec laptops, but not a xeon cpu rack server for example.
I’m assuming the two threads which need to be started, have their own windows? If yes, you should use rohitab to look at the amount of work that goes into 1) opening a new window, 2) reading the ini file and 3) opening any files. #2 & #3 are very slow but those three bits of a procedure are very intensive, and thats where your locks up will occur. Windows is very busy doing those three bits and MDI windows are slower more intensive for windows to open than a non-MDI aka SDI window.
I’ve specified 50,000 because ram is cheap and abundant now a days, unlike say the 8088 days.
Stack overflow - Wikipedia
TopSpeed / Clarion / JPI x86 calling conventions - Wikipedia