none
Adding a FolderWatch to a streaming application?

    Question

  • A little background - I've created an application that pulls the video feed from Video Intercom (Algo 8036) we have at the front door of our building and displays in a window on a PC. It's not an actual video stream as the intercom unit creates a JPG every 100ms and the app repeatedly grabs that every 250ms. With several people using the app, the intercom unit tends to bog down so I've set it so when the app is not "on top" it pauses the video.This, of course has it's own problems in that people who answer these calls forget to bring the app to the front before letting people into the building.

    The intercom sends entries to a syslog and when motion is detected, the syslog application is configured to update a text file. I've created a Watcher to monitor the text file, but it seems the watcher is running once and then never captures changes. I can't seem to make it "persistent" and I'm looking for ideas on how to do that. All the info I've seen seems to have to watcher as a standalone app. The watcher code I'm using is below:

    //I've tried this in a void, as a separate thread, and in the public section at the top of the form code
    FileSystemWatcher watcher = new FileSystemWatcher("\\\\SERVER_NAME\\CamView_Watch", "camviewer.log");
    watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess;
    watcher.Filter = "*.log";
    watcher.Changed += OnChanged;
    watcher.EnableRaisingEvents = true;
    
    private void OnChanged(object source, FileSystemEventArgs e) =>
    MessageBox.Show($"File: {e.FullPath} {e.ChangeType}");

    Any help would be greatly appreciated!

    Friday, May 24, 2019 12:56 PM

All replies

  • Hi pkirill-vea,

    Thank you for posting here.

    Based on your description, you want to make the watcher persistent.

    I have tested the code, it works well. I think the problem may be that the system log file is not updated. So I suggest that you could open the log file manually to see if it has been changed after motion is detected.

    Test Result:

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 27, 2019 2:19 AM