FileSystemWatcher的网络断开连接网络、FileSystemWatcher

2023-09-03 11:15:13 作者:一吻葬花离

我有一个FileSystemWatcher的网络共享监视的文件。如果发生的事件,以使共享不可用,也许由于网络问题,FileSystemWatcher的断开连接。

I have a FileSystemWatcher monitoring a file on a network share. If an event occurs to make the share unavailable, maybe due to a network problem, the FileSystemWatcher becomes disconnected.

显然,我可以处理的错误事件,也许做一些记录和很多文章建议重新连接FSW错误事件处理中。

Obviously I can handle the "Error" event, maybe do some logging and lots of articles suggest reconnecting the FSW inside the error event handler.

但是,如果网络共享仍是错误事件中不可用。然后,我需要引入一个定时器来测试网络共享可用,并尝试重新连接FSW。

But what if the network share is still unavailable inside the error event. I then need to introduce a timer to test if the network share is available and attempt to reconnect the FSW.

1)是否有更好的方法?

1) Is there a better approach?

2)是否有一个属性,它让我确定了FSW已断开的文件?我注意到有搅拌摩擦焊的stopListening,这似乎是设置为true时,FSW不可连接的非公共成员。但是,这不是公开暴露

2) Is there a property that allows me to determine that the FSW has become disconnected from the file? I notice there is a non-public member of the FSW "stopListening", which appears to be set to true when the FSW becomes disconnected. But this is not publicly exposed

任何帮助将是AP preciated ...

Any help would be appreciated ...

谢谢 凯文

推荐答案

后续在此。在对MSDN论坛微软资源的建议,我已将此添加到微软连接。

Follow-up in this. At the suggestion of a Microsoft resource on the MSDN forums, I added this to Microsoft Connect.

从微软反馈要点: - 错误事件不仅对内部缓冲区溢出 - 他们将增加暴露的可能性的的stopListening 的属性,以他们的客户建议列表

Key points from the feedback from Microsoft: - Error event is not only for internal buffer overflows - They will add the possibility of exposing the stopListening property to their list of customer suggestions

链接的位置:http://connect.microsoft.com/VisualStudio/feedback/details/727934/filesystemwatcher-error-handling