I have a program that does a large number of comparisons. It compares a specific .dat file saved on the local machine to a large number of other files that are generated on run-time. Right now I am unable to perform these comparisons using multiple threads because of many System.AccessViolationException
. I'm assuming this is because multiple threads are trying to access the same local file at the same time. How can I overcome this to do these comparisons with multiple threads?
There are several possible reasons for your access violation:
The following solutions exist:
As Matthew Watson correctly points out, an AccessViolationException
is caused by errors in unmanaged code, so it is probably not caused by multiple threads trying to access the same file.
My answer therefore assumes that you are actually getting an UnauthorizedAccessException
.
If that is not the case and you are indeed getting an AccessViolationException
your problem most likely lies elsewhere.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.