//-----------------------------------------------------------------------------// /// <summary> /// Do the work in a separate thread, monitor the time it takes, and kill it if /// it takes too long. /// </summary> /// <returns></returns> private DirectoryInfo[] ThreadMonitoredGetDirectories(DirectoryInfo startDir) { GetDirectoryiesThread dirThread = new GetDirectoryiesThread(startDir); dirThread.Start(); DateTime startTime = DateTime.Now; while (dirThread.WorkingDirInfoArr == null) { Thread.Sleep(1); if (DateTime.Now.Subtract(startTime).Ticks > this.tickTimeOut) { dirThread.Abort(); this.getDirectoiesThreadAbortCount++; break; } } return(dirThread.WorkingDirInfoArr); }
//-----------------------------------------------------------------------------// /// <summary> /// Do the work in a separate thread, monitor the time it takes, and kill it if /// it takes too long. /// </summary> /// <returns></returns> private DirectoryInfo[] ThreadMonitoredGetDirectories( DirectoryInfo startDir ) { GetDirectoryiesThread dirThread = new GetDirectoryiesThread( startDir); dirThread.Start(); DateTime startTime = DateTime.Now; while ( dirThread.WorkingDirInfoArr == null ) { Thread.Sleep(1); if (DateTime.Now.Subtract(startTime).Ticks > this.tickTimeOut) { dirThread.Abort(); this.getDirectoiesThreadAbortCount++; break; } } return dirThread.WorkingDirInfoArr; }