|
@@ -5,32 +5,40 @@ using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Timers;
|
|
using System.Timers;
|
|
|
|
+using System.IO;
|
|
|
|
|
|
namespace BaiduYunBeiFen.Controller
|
|
namespace BaiduYunBeiFen.Controller
|
|
{
|
|
{
|
|
- public class FileGuanliContorller
|
|
|
|
|
|
+ //静态控制器
|
|
|
|
+ public static class FileGuanliContorller
|
|
{
|
|
{
|
|
- System.Timers.Timer MainTimer;
|
|
|
|
- delegate void RunFuntion();
|
|
|
|
- static int InterValTime = 1000;
|
|
|
|
- static int num = 1000;
|
|
|
|
-
|
|
|
|
- public void InitTimeThread()
|
|
|
|
|
|
+ //初始化计时器
|
|
|
|
+ static System.Timers.Timer MainTimer = new();
|
|
|
|
+ //计时器初始运行间隔
|
|
|
|
+ static int InterValTime = 5000;
|
|
|
|
+ private static string CheckPath = "";
|
|
|
|
+ static string[]? FilePaths;
|
|
|
|
+ //赋予计时器初始事件
|
|
|
|
+ public static void InitTimeThread()
|
|
{
|
|
{
|
|
MainTimer = new System.Timers.Timer(InterValTime);
|
|
MainTimer = new System.Timers.Timer(InterValTime);
|
|
MainTimer.Elapsed += OnTimedEvent;
|
|
MainTimer.Elapsed += OnTimedEvent;
|
|
}
|
|
}
|
|
- public void StartTimeThread()
|
|
|
|
|
|
+
|
|
|
|
+ //运行计时器
|
|
|
|
+ public static void StartTimeThread()
|
|
{
|
|
{
|
|
MainTimer.Start();
|
|
MainTimer.Start();
|
|
}
|
|
}
|
|
|
|
|
|
- public void StopTimeThread()
|
|
|
|
|
|
+ //停止计时器
|
|
|
|
+ public static void StopTimeThread()
|
|
{
|
|
{
|
|
MainTimer.Stop();
|
|
MainTimer.Stop();
|
|
}
|
|
}
|
|
|
|
|
|
- public void ChangeValTime(int ValTime)
|
|
|
|
|
|
+ //修改计时器运行间隔
|
|
|
|
+ public static void ChangeValTime(int ValTime)
|
|
{
|
|
{
|
|
MainTimer.Stop();
|
|
MainTimer.Stop();
|
|
MainTimer = new System.Timers.Timer(ValTime);
|
|
MainTimer = new System.Timers.Timer(ValTime);
|
|
@@ -38,9 +46,15 @@ namespace BaiduYunBeiFen.Controller
|
|
MainTimer.Start();
|
|
MainTimer.Start();
|
|
}
|
|
}
|
|
|
|
|
|
- private void OnTimedEvent(Object source, ElapsedEventArgs e)
|
|
|
|
|
|
+ //初始计时器事件
|
|
|
|
+ private static void OnTimedEvent(Object? source, ElapsedEventArgs e)
|
|
{
|
|
{
|
|
- Console.WriteLine("定时事件触发在 {0:HH:mm:ss.fff}", e.SignalTime);
|
|
|
|
|
|
+ CheckPath = Directory.GetCurrentDirectory();
|
|
|
|
+ FilePaths = Directory.GetFiles(CheckPath);
|
|
|
|
+ foreach (string item in FilePaths)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|