It is not easy to debug multithreading application because of threads jumping and interleaving each other. When I was debugging some algorithms, I always change the application setting to single threaded.
Things could be a lot easier. Delphi has a IsDebuggerPresent function that declares the Win32 API.
unit Windows; .. .. function IsDebuggerPresent: boolean; external 'kernel32.dll';
It can be used to detect if IDE or debugger is present. Therefore, I could just add the following code:
{$IFDEF DEBUG} if (IsDebuggerPresent) then ThreadNumber := 1; {$ENDIF}
The above code allows you to force debug single-threaded application and you don’t need to change any single line of code when you want to deploy your application as multithreading. The compiler directive check {$IFDEF DEBUG} makes sure the above code only is injected to the production binaries which is RELEASE mode.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: SQL Exercise - How to Swap Columns? (MySQL)
Next Post: LOGO Turtle Tutorial How to Draw Fractal Stars?