我有这堂课来证明我的问题:
class Program
{
static List<FileInfo> _foundFiles;
static int _numberPadding = 0;
static Thread newThread;
static void Main(string[] args)
{
_foundFiles = new List<FileInfo>();
_shouldStop = false;
newThread = new Thread(new ThreadStart(StartSearch));
newThread.Start();
newThread.Join();
Console.WriteLine("Finished");
Console.ReadKey();
}
static volatile bool _shouldStop;
static void StartSearch()
{
IterateFileSystemNon(new DirectoryInfo(@"D:\OLD Melman\Music Backup\iTunes 28-06-11\Music"));
}
static void IterateFileSystemNon(DirectoryInfo folder)
{
string pad = CreatePadding();
Console.WriteLine("{0} Directory: {1}", pad, folder.Name);
foreach (var dir in folder.GetDirectories())
IterateFileSystemNon(dir);
pad = CreatePadding();
foreach (var file in folder.GetFiles())
{
if (file.Extension.Contains("mp3"))
{
_foundFiles.Add(file);
Console.WriteLine("{0} File: {1}", pad, file.Name);
}
}
_numberPadding = _numberPadding - 6;
}
static string CreatePadding()
{
_numberPadding = _numberPadding + 3;
var stringRepOfPadding = new StringBuilder(_numberPadding);
for (int i = 0; i < _numberPadding; i++)
{
stringRepOfPadding.Append(" ");
}
return stringRepOfPadding.ToString();
}
}
我有这些问题:
Join
语句,为什么会这样?答案 0 :(得分:1)
答案 1 :(得分:0)
Thread
构造函数的方法返回。 (在你的情况下StartSearch
)。