开发者

Access denied from another thread

In a program I span a开发者_运维问答 thread ("the working thread"). Hera I copy some files write some data to a database and eventually, delete some other files or directories. Everything works fine. The problem is now, that I decided to move the deleting operation to some other thread. So the working thread now copies the files or directories, writes to the database, and , if there is a need to delete some other files this thread spans another thread and that second thread deleted the needed files or directories.

The problem is that,the deletion used to work 100% when done in the working thread, now when the same is done in the secondary thread, I sometimes get an "Access denied" error and the files cannot be deleted. And no, the working thread is definitely NOT acceding the files and directories to delete at this moment.

Sometimes (but not always) the main thread is impersonating some user, so if needed , the deleting thread is also running under impersonation just to grant the needed permissions to delete the files, so that should not be the problem.

Anybody has a clue why this could be happening?


Use Process Explorer to check what holds locks on your files.


I don't really think this is related... But try disabling Window's Prefetch. We had a lot of trouble caused by Prefetch locking files we were manipulating, but that was on application's startup. As far as I know, Prefetch should only be reading files when system boots and when application starts (Depending on current configuration value), but maybe it does too when creating a new thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜