Changeset 1755


Ignore:
Timestamp:
02/08/10 03:48:49 (5 years ago)
Author:
lowjoel
Message:

Forward port from Eraser 6.0: 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.

Location:
trunk/eraser6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6

  • trunk/eraser6/Eraser.Manager/DirectExecutor.cs

    r1712 r1755  
    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            } 
     
    615630                            "not be erased because the file was either compressed, encrypted or " + 
    616631                            "a sparse file.", info.FullName), LogLevel.Error)); 
     632                        continue; 
    617633                    } 
    618634 
Note: See TracChangeset for help on using the changeset viewer.