gpt4 book ai didi

c# - filesystemwatcher 多个文件

转载 作者:太空宇宙 更新时间:2023-11-03 14:25:08 27 4
gpt4 key购买 nike

我对在 C# 中使用 FileSystemWatcher 有疑问。
当在指定文件夹中创建文件时,我需要得到通知,但问题是如果我同时创建多个文件,则会触发多个事件,我需要代码仅在处理了前一个文件而不处理前一个文件时才继续同时保存多个文件。

知道怎么做吗?

非常感谢

最佳答案

伪代码:

bool wasLastObjectProcessed = true

function onFileWatcherCreateFile
lock wasLastObjectProcessed
if wasLastObjectProcessed and processFile(file)
#do some code here that you need to do if it is processed
else
wasLastObjectProcessed = false
endif
endlock
endfunction

关于c# - filesystemwatcher 多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4306193/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com