Nice having you here.

TIA
Roman
Moderators: Hacker, petermad, Stefan2, white
There is nothing special, SC only uses a background thread for accessing network folders.Hacker wrote:Sven,
Nice having you here.I wonder if you could help us with this problem http://ghisler.ch/board/viewtopic.php?t=2937 . Would be nice if you'd be willing to. I (and everyone) would of course understand if you wouldn't, too.
You will not believe me, but I can't duplicate this behaviour. As said before there is nothing special, SC uses only a background thread. However, it might be related to the development environment.Hacker wrote:Hmm, in this thread - http://ghisler.ch/board/viewtopic.php?t=3051 , Christian is quoted as saying,
"...I was disappointed by Windows! Example: When I try to read a directory from a server on the net which has crashed, this will hang not only the current thread, but also all other threads of the same program which call any directory function, even with local folders - until the hanging connection times out! Yes, I tried all kinds of things to get rid of the thread when it was hanging (just ignoring the trhead, killing the thread), but unfortunately nothing worked."
How do you solve this?
Then what do you do when the user cancels the connection? I tried the followingYou will not believe me, but I can't duplicate this behaviour. As said before there is nothing special, SC uses only a background thread.
Therefore I don't know whether it's such a good idea to use TerminateThread: FindFirstFile is a Kernel32 call, and the above explicitly warns NOT to call TerminateThread during such a Kernel32 call, because the Kernel32 state for the entire process would become inconsistent. I also don't know whether the function currently uses a critical section. So even if it works fine on some Windows versions, it may cause damage on other versions.TerminateThread is a dangerous function that should only be used in the most extreme cases. You should call TerminateThread only if you know exactly what the target thread is doing, and you control all of the code that the target thread could possibly be running at the time of the termination. For example, TerminateThread can result in the following problems:
· If the target thread owns a critical section, the critical section will not be released.
· If the target thread is executing certain kernel32 calls when it is terminated, the kernel32 state for the thread's process could be inconsistent.
· If the target thread is manipulating the global state of a shared DLL, the state of the DLL could be destroyed, affecting other users of the DLL.
You are right, I just realized, that Christian wrote about calling FindFirstFile. That is a pure API call, with no wrapper around it. My mistake.And I also think Christian is using as few internal Delphi functions as possible, doing almost everything through the WinAPI