Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying data being used in a thread
    primarykey
    data
    text
    <p>Okay, so my issue is that I have to catch delete and rename events (which) I can do. And modify the data in threads to handle this so that the deleted files are removed and the renamed files have their data changed. This is psuedo-code for the system, just to get an idea of what it looks like. Whenever I delete, the system throws an exception, however it is not caught, so I have been having a hard time figuring out how to go about solving or rewriting the solution. The other portion of this is that I will have multiple managers running at once, but I figure if I can't get one to work... then this is futile.</p> <pre><code>Main { public void Run() { List&lt;FileInfo&gt; someData = new List&lt;FileInfo&gt;(); FileWatcher fileWatcher = new FileWatcher(@"C:\USers\user1\Documents"); fileWatcher.NotifyFilter = NotifyFilter.Last fileWatcher.Deleted += new FileSystemEventHandler(OnDelete); fileWatcher.EnableRaisingEvents = true; Manager aManager = new Manager(someData); Thread aThread = new Thread(new ThreadStart(aManager.ExecuteTask)); aThread.Start(); } static void OnDelete(object sender, Event e) { aManager.Pause(); aManager.RemoveData(e.FileInfo); aManager.Resume(); } } Manager { ExecuteTask() { while(someData.Count &gt; 0) { while (paused) ; // &lt;- This is something I am trying to add PreformSubTask(someData[0]); } } PreformSubTask() { lock (_locker) { Worker someWorker = new Worker(someData[0]); Thread someThread = new Thread(new ThreadStart(worker.ExecuteTask())); } worker.Join(someSetOfTime); lock(_locker) { someData.RemoveAt(0); } } Pause() { lock (_locker) { if (!paused) paused = true; } } Resume { lock (_locker) { if (paused) paused = false; } } RemoveData(FileInfo toRemove) { someData.RemoveAll(sd =&gt; sd.Equals(someData)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload