繁体   English   中英

FileSystemWatcher是否创建自己的线程?

[英]Does FileSystemWatcher create its own thread?

我希望这项工作在不同的线程中完成,但我是否必须创建一个线程或者它是否在不同的线程上完成所有工作?

喜欢:

Thread fileThread = new Thread(() =>
{
    FileWatcher = new FileSystemWatcher();

    FileWatcher.Created += OnFileEvent;
    FileWatcher.Deleted += OnFileEvent;
    FileWatcher.Renamed += OnRenameEvent;
    FileWatcher.EnableRaisingEvents = true;
});

fileThread.Start();

您不必创建线程。 事件将在一个单独的线程上自动调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM