Greetings.
In my Console Application, I have a process that connects to a Access Database File. After closing the connection I copy the file to another folder, and delete the original.
Lately this is failing a lot. For some reason the File is still being used, even if the connection is closed.
I think that the problem is the speed at which it's doing everything, I try to delete it right after the closeConnection() method. And the connection might not be fully closed??? This is something that I don't fully understand yet.
Anyways, I wanted to add a small timer (this application doesn't have to run with a time constraint so I don't mind waiting).
I've read here on the forums that people use Thread.Sleep().
Is that safe? It seemed to work when I tested it. But is this the correct way to do it? Does anyone have any insight or any different idea on how to fix this "File currently in use" problem?
Regards to all,
CB.
EDIT: I don't use threads, nor tasks... The code execution is linear. .NET 4.0