优化 Mjpeg 播放

This commit is contained in:
2026-01-22 14:06:44 +08:00
parent c438edfa0d
commit 6661edfc44
4 changed files with 111 additions and 105 deletions

View File

@@ -47,30 +47,26 @@ namespace SHH.MjpegPlayer
try
{
var process = Process.GetProcessById(pid);
if (process != null)
{
procName = process.ProcessName;
process.Kill();
_sysLog.Warning("拒绝停止高权限系统进程: {Pid} - {Name}", pid, process.ProcessName);
_sysLog.Information("成功通过 PID 杀掉进程 - Pid: {Pid}, Name: {Name}", pid, procName);
return true;
}
else
{
// 找不到 ID 对应的进程,应该是进异常不会进这里
_sysLog.Information("成功杀掉进程 - Pid: {Pid}", pid);
return false;
}
_sysLog.Warning("无法获取进程实例 - Pid: {Pid}", pid);
return false;
}
catch (ArgumentException)
{
_sysLog.Warning("杀掉进程失败Pid: {Pid} 不存在", pid);
_sysLog.Warning("杀掉进程失败Pid: {Pid} 不存在或已提前退出", pid);
return false;
}
catch (Exception ex)
{
_sysLog.Error(ex, "杀掉进程异常, Pid: {Pid}", pid);
_sysLog.Error(ex, "杀掉进程异常, Pid: {Pid}, 进程名: {Name}", pid, procName);
return false;
}
}