Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does FileSystemWatcher create its own thread?

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();
like image 708
syncis Avatar asked Jul 15 '12 14:07

syncis


Video Answer


1 Answers

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

like image 193
Guffa Avatar answered Sep 20 '22 14:09

Guffa