Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 415.9k

file is being used by another process in background thread?

Oct 22 2013 1:56 AM

Hi all,

I am working on C# app which is using backgroundworker thread for uploading and downloading the files.

In my code i am using one generic class name "INFO", which contain all information of file which will upload.i am creating one list of "Info" class and i am assigning info class's object to backgroundworker Threads using "ForLoop".Its is working fine but some times it gives an error " The process cannot access the file because it is being used by another process" 

I searched on google and found a mechanism "Lock(this)" for lock my files while uploading ,but  due to this i faced another issue "uptill all previous threads will not finished their work it will not start newly assigned threads uploading process.

to resolving this issue i found another mechanism on google "Monitor.enter(obj)" ,but again ii faced same issue" The process cannot access the file because it is being used by another process" 

Please help me out from this issue thus i will upload newly assigned threads file.

Thanks


Answers (2)