It happened when returning from a form, but I also got it when trying to start a new thread which would load a browse window or some other window.
I tried tricks like slowing down the hardware acceleration
Display Hardware Acceleration Slider - Windows drivers | Microsoft Learn
This doesnt apply if the graphics is provided by the cpu, but does apply if using an addon graphics card.
Win10> Settings > Display> scroll to the bottom and click on Graphics Settings, and toggle the hardware accelerated GPU scheduling. I havent seen the slider mentioned in the MS link above in Win10.
The slider referred to in the link is available from W2k to Win7. I dont know about Win8, but the GPU scheduling options have changed in Win10.
I never could get to the bottom of it, ie could reproduce it in code, but as you can see on my other post in your other thread, because I also had the situation where two clarion apps that communicated via pipes would both freeze when I was only debugging one of them, I needed a way to eliminate the clarion runtime which is why I went with the non clarion app debugview to get msgs out of the clarion apps to narrow down where it was freezing.
The closest I got to narrowing it down, but at the time couldnt replicate with MS api’s was the MDI child windows opening and closing. Using rohitab to watch the api calls, the clarion mdi child window calls worked in a particular way which contradicted code examples I had seen elsewhere. From memory I think two api’s calls were in the wrong order in the clarion runtime.
So its possible to open a mdi child window maximised, but the clarion runtime opens the window at a set size, then looks up the ini file window state and size then changes the window to suit. It was around here that the api calls were different to code examples I’d seen elsewhere.
I havent looked into the api calls with clarion 11. The tool I used to monitor the api calls was rohitab api monitor. You can select the windows dll’s and then select the api’s you want to monitor and it creates a hook into the process (app) and then displays all the api calls with parameter data so you can get a good insight into what is happening inside nearly any program.
If you have the hardware acceleration option, by switching this off, you make your pc more like they used to be in the early days where everything was done by the cpu and separate graphics cards didnt exist. That can help with scheduling.
Something else which can help with cpu scheduling it to alter the quantum. If you want to give background tasks more cpu time, this can help with machines not using windows defender for their anti virus.
Know Thy Tick | Microsoft Learn
Look for Win32PrioritySeparation on this link and the different quanta, you can set it to.
FAQ of the Software/Operating Systems section | guru3D Forums
I normally run a 0x26 for a super responsive main app with no lag or minimal lag, but other tasks including services get less cpu time as a result and this can cause the less well written one’s problems especially if they use a driver which some AV software does. (This sounds like some car meet discussing fuel octane, cylinder pressures, injector nozzles, turbo’s etc but it works.)
There is a whole host of possibilities which could be affecting your machine making the apps freeze. Anti virus programs are notorious for interfering with other apps, so adding your app to any ignore list the AV software might have, can help as its reduces what can interfere with your app.
One other thought, when exiting the form, does this typically happen when data is being saved or abandoned like clicking changed and then clicking cancel? If its happening when data is being saved, what are you using for your data source? Tps files? SQL server of sorts? If SQL server is this a server based sql server or one running on the same machine?