Does FileSystemWatcher create its own thread?

北城余情 提交于 2019-11-26 16:51:16

问题


I want this work to be done in a different thread but do i have to create a thread or does it do all the work on different threads?

Like:

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

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

fileThread.Start();

回答1:


You don't have to create a thread. The events will be called on a separate thread automatically.



来源:https://stackoverflow.com/questions/11492720/does-filesystemwatcher-create-its-own-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!