Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FileSystemWatcher Delay

FileSystemWatcher Delay

Scheduled Pinned Locked Moved C#
sysadmincsharpquestion
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zishan Haider
    wrote on last edited by
    #1

    I have an application that communicates with the server program through a shared text file, located at a network directory. The server writes to the text file which my application reads. I am using FileSystemWatcher to monitor this file. Now when server writes to the file, change event in my application fires after 2 or 3 seconds. However when I manually change this file and save it, it acts the ideal way. I want to reduce this time delay as this should act like realtime system. My C# code goes like this : ------------------------------------------------------------------- public MyWatcherClass() { watcher = new FileSystemWatcher(); this.watcher.Path = this.MyNetworkDrive; this.watcher.NotifyFilter = NotifyFilters.Size; this.watcher.Filter = this.MyTextFile; this.watcher.Changed += new FileSystemEventHandler(OnChanged); this.watcher.EnableRaisingEvents = true; } ------------------------------------------------------------------- What am I missing? Thanks in advance

    L 1 Reply Last reply
    0
    • Z Zishan Haider

      I have an application that communicates with the server program through a shared text file, located at a network directory. The server writes to the text file which my application reads. I am using FileSystemWatcher to monitor this file. Now when server writes to the file, change event in my application fires after 2 or 3 seconds. However when I manually change this file and save it, it acts the ideal way. I want to reduce this time delay as this should act like realtime system. My C# code goes like this : ------------------------------------------------------------------- public MyWatcherClass() { watcher = new FileSystemWatcher(); this.watcher.Path = this.MyNetworkDrive; this.watcher.NotifyFilter = NotifyFilters.Size; this.watcher.Filter = this.MyTextFile; this.watcher.Changed += new FileSystemEventHandler(OnChanged); this.watcher.EnableRaisingEvents = true; } ------------------------------------------------------------------- What am I missing? Thanks in advance

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Call Flush after writing to the file, else it will be buffered. xacc-ide 0.0.10 now with C#, MSIL, C and HLSL coloring - Screenshots

      A 1 Reply Last reply
      0
      • L leppie

        Call Flush after writing to the file, else it will be buffered. xacc-ide 0.0.10 now with C#, MSIL, C and HLSL coloring - Screenshots

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Off course I am already doing it. Didn't anyone else experince it?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups