Changeset 1754 for branches/eraser6/6.0


Ignore:
Timestamp:
2/8/2010 3:38:30 AM (2 years ago)
Author:
lowjoel
Message:

Fixed two errors in the code: when terminating the DirectExecutor? thread, we may return from Dispose before the thread exists. Call Join, pumping messages if it is on the main thread so that such invocation calls will not throw InvalidAsynchronousStateExceptions?. In addition, when erasing files which we cannot deal with (sparse/compressed/encrypted) we need to skip the file; the old code did not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0/Eraser.Manager/DirectExecutor.cs

    r1719 r1754  
    5656                thread.Abort(); 
    5757                schedulerInterrupt.Set(); 
     58 
     59                //Wait for the executor thread to exit -- we call some event functions 
     60                //and these events may need invocation on the main thread. So, 
     61                //pump messages from the main thread until the thread exits. 
     62                if (System.Windows.Forms.Application.MessageLoop) 
     63                { 
     64                    if (!thread.Join(new TimeSpan(0, 0, 0, 0, 100))) 
     65                        System.Windows.Forms.Application.DoEvents(); 
     66                } 
     67 
     68                //If we are disposing on a secondary thread, or a thread without 
     69                //a message loop, just wait for the thread to exit indefinitely 
     70                else 
     71                    thread.Join(); 
     72 
    5873                schedulerInterrupt.Close(); 
    5974            } 
     
    760775                            "not be erased because the file was either compressed, encrypted or " + 
    761776                            "a sparse file.", info.FullName), LogLevel.Error)); 
     777                        continue; 
    762778                    } 
    763779 
Note: See TracChangeset for help on using the changeset viewer.