diff --git a/src/CAD/IFox.CAD.Shared/ExtensionMethod/CurveEx.cs b/src/CAD/IFox.CAD.Shared/ExtensionMethod/CurveEx.cs index 68b286ffb2d13138f2970c888364331a70413730..905d38f855f5452b0390de47a84eaa806ef2ddb5 100644 --- a/src/CAD/IFox.CAD.Shared/ExtensionMethod/CurveEx.cs +++ b/src/CAD/IFox.CAD.Shared/ExtensionMethod/CurveEx.cs @@ -187,7 +187,7 @@ public static List BreakCurve(this List curves) if (pars1.Count > 0) { var c3ds = gc1.GetSplitCurves(pars1); - if (c3ds.Count > 1) + if (c3ds is not null && c3ds.Count > 1) { foreach (var c3d in c3ds) { diff --git a/src/CAD/IFox.CAD.Shared/IFox.CAD.Shared.projitems b/src/CAD/IFox.CAD.Shared/IFox.CAD.Shared.projitems index ecb9c9a2bdd69f73c5f0ad0f755055eb832a40a4..b53f25cbc82fc563c0058eaaf59ceb0f8d31fa24 100644 --- a/src/CAD/IFox.CAD.Shared/IFox.CAD.Shared.projitems +++ b/src/CAD/IFox.CAD.Shared/IFox.CAD.Shared.projitems @@ -74,6 +74,7 @@ + diff --git a/src/CAD/IFox.CAD.Shared/Runtime/IAutoGo.cs b/src/CAD/IFox.CAD.Shared/Runtime/IAutoGo.cs index 6eed7e2bb98f29c27f0307ae6d219772cdb3bd48..3b71d4cb856acc3ef17e3caf6fce7e1d5ec41ec6 100644 --- a/src/CAD/IFox.CAD.Shared/Runtime/IAutoGo.cs +++ b/src/CAD/IFox.CAD.Shared/Runtime/IAutoGo.cs @@ -132,7 +132,7 @@ public void Initialize() RunFunctions(_InitializeList); } } - catch (System.Exception e) + catch { Debugger.Break(); } diff --git a/src/CAD/IFox.CAD.Shared/Runtime/IdleAction.cs b/src/CAD/IFox.CAD.Shared/Runtime/IdleAction.cs new file mode 100644 index 0000000000000000000000000000000000000000..6431391ea8bfad21ec9960389db4b1cc09054383 --- /dev/null +++ b/src/CAD/IFox.CAD.Shared/Runtime/IdleAction.cs @@ -0,0 +1,58 @@ +namespace IFoxCAD.Cad; + +/// +/// 空闲执行 +/// by DYH +/// 20230114 +/// +public static class IdleAction +{ + /// + /// 是否已经加载 + /// + private static bool alreadyLoad = false; + /// + /// 委托列表 + /// + private static readonly List actions = new(); + /// + /// 未处理的委托数量 + /// + public static int Count { get { return actions.Count; } } + /// + /// 添加空闲执行委托 + /// + /// 委托 + public static void Add(Action action) + { + actions.Add(action); + if (!alreadyLoad) + { + Acap.Idle -= Acap_Idle; + Acap.Idle += Acap_Idle; + alreadyLoad = true; + } + } + /// + /// 空闲处理事件 + /// + /// Acap + /// 事件参数 + private static void Acap_Idle(object sender, EventArgs e) + { + if (Count == 0) + { + alreadyLoad = false; + Acap.Idle -= Acap_Idle; + return; + } + try + { + actions[0]?.Invoke(); + } + finally + { + actions.RemoveAt(0); + } + } +}