ntminer 5 år sedan
förälder
incheckning
9457d4d15c

+ 1 - 0
src/AppViews0/Ucs/MessagePathIds.xaml

@@ -35,6 +35,7 @@
                         </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>
                 </DataGridTemplateColumn>
+                <DataGridTextColumn Header="ViaLimit" Binding="{Binding ViaLimit}"></DataGridTextColumn>
                 <DataGridTextColumn Header="MessageType" Binding="{Binding MessageType.FullName}"></DataGridTextColumn>
                 <DataGridTextColumn Header="Location" Binding="{Binding Location.FullName}"></DataGridTextColumn>
                 <DataGridTextColumn Header="LogType" Binding="{Binding LogType}"></DataGridTextColumn>

+ 1 - 0
src/NTMinerBus/Bus/MessageDispatcher.cs

@@ -36,6 +36,7 @@
                                 tMessageHandler.ViaLimit--;
                                 if (tMessageHandler.ViaLimit == 0) {
                                     _handlers[messageType].Remove(messageHandler);
+                                    Disconnected?.Invoke(tMessageHandler);
                                 }
                             }
                         }

+ 13 - 2
src/NTMinerBus/Bus/MessagePath`1.cs

@@ -5,9 +5,10 @@ namespace NTMiner.Bus {
     public class MessagePath<TMessage> : IMessagePathId, INotifyPropertyChanged {
         private readonly Action<TMessage> _path;
         private bool _isEnabled;
+        private int _viaLimit;
 
         public event PropertyChangedEventHandler PropertyChanged;
-        
+
         public static MessagePath<TMessage> Build(IMessageDispatcher dispatcher, Type location, string description, LogEnum logType, Action<TMessage> action, int viaLimit = -1) {
             if (action == null) {
                 throw new ArgumentNullException(nameof(action));
@@ -28,7 +29,15 @@ namespace NTMiner.Bus {
             ViaLimit = viaLimit;
         }
 
-        public int ViaLimit { get; internal set; }
+        public int ViaLimit {
+            get => _viaLimit;
+            internal set {
+                _viaLimit = value;
+#if DEBUG
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ViaLimit)));
+#endif
+            }
+        }
         public Type MessageType { get; private set; }
         public Type Location { get; private set; }
         public string Path { get; private set; }
@@ -38,7 +47,9 @@ namespace NTMiner.Bus {
             get => _isEnabled;
             set {
                 _isEnabled = value;
+#if DEBUG
                 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsEnabled)));
+#endif
             }
         }
 

+ 3 - 8
src/NTMinerClient/NTMinerRoot.partials.MinerProcess.cs

@@ -37,18 +37,13 @@ namespace NTMiner {
                             if (Instance.GpuProfileSet.IsOverClockEnabled(mineContext.MainCoin.GetId())) {
                                 Write.UserWarn("应用超频,如果CPU性能较差耗时可能超过1分钟,请耐心等待");
                                 var cmd = new CoinOverClockCommand(mineContext.MainCoin.GetId());
-                                // N卡超频当cpu性能非常差时较耗时,所以这里弄个回调
-                                IMessagePathId callback = null;
-                                callback = VirtualRoot.BuildEventPath<CoinOverClockDoneEvent>("超频完成后继续流程", LogEnum.DevConsole,
+                                VirtualRoot.BuildOnecePath<CoinOverClockDoneEvent>("超频完成后继续流程", LogEnum.DevConsole,
                                     message => {
-                                        if (mineContext != Instance.LockedMineContext) {
-                                            VirtualRoot.DeletePath(callback);
-                                        }
-                                        else if (message.CmdId == cmd.Id) {
-                                            VirtualRoot.DeletePath(callback);
+                                        if (mineContext == Instance.LockedMineContext) {
                                             ContinueCreateProcess(mineContext);
                                         }
                                     });
+                                // 超频是在另一个线程执行的,因为N卡超频当cpu性能非常差时较耗时
                                 VirtualRoot.Execute(cmd);
                             }
                             else {