File tree Expand file tree Collapse file tree 4 files changed +22
-7
lines changed
OneScript.DebugProtocol/TcpServer Expand file tree Collapse file tree 4 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ public DefaultMessageServer(ICommunicationChannel protocolChannel)
2121 {
2222 _protocolChannel = protocolChannel ;
2323 }
24+
25+ /// <summary>
26+ /// Имя, назначаемое потоку сервера. Полезно для отладки и диагностики.
27+ /// </summary>
28+ public string ServerThreadName { get ; set ; }
2429
2530 public void Start ( )
2631 {
@@ -76,6 +81,12 @@ private void RunCommandsLoop()
7681 }
7782 } ) ;
7883
84+ _messageThread . IsBackground = true ;
85+ if ( ServerThreadName != default )
86+ {
87+ _messageThread . Name = ServerThreadName ;
88+ }
89+
7990 _messageThread . Start ( ) ;
8091 }
8192
Original file line number Diff line number Diff line change @@ -5,26 +5,28 @@ This Source Code Form is subject to the terms of the
55at http://mozilla.org/MPL/2.0/.
66----------------------------------------------------------*/
77
8+ using System ;
89using System . Threading ;
910using ScriptEngine . Machine ;
1011
1112namespace OneScript . DebugServices
1213{
13- public class MachineWaitToken
14+ public class MachineWaitToken : IDisposable
1415 {
15- private ManualResetEventSlim _threadEvent ;
16+ private ManualResetEventSlim _threadEvent = new ManualResetEventSlim ( ) ;
1617
17- public MachineWaitToken ( )
18- {
19- _threadEvent = new ManualResetEventSlim ( ) ;
20- }
21-
2218 public MachineInstance Machine { get ; set ; }
2319
2420 public void Wait ( ) => _threadEvent . Wait ( ) ;
2521
2622 public void Set ( ) => _threadEvent . Set ( ) ;
2723
2824 public void Reset ( ) => _threadEvent . Reset ( ) ;
25+
26+ public void Dispose ( )
27+ {
28+ Machine . UnsetDebugMode ( ) ;
29+ _threadEvent . Dispose ( ) ;
30+ }
2931 }
3032}
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ public void Dispose()
8787 foreach ( var machineWaitToken in tokens )
8888 {
8989 machineWaitToken . Machine . MachineStopped -= Machine_MachineStopped ;
90+ machineWaitToken . Dispose ( ) ;
9091 }
9192
9293 _machinesOnThreads . Clear ( ) ;
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ public void SetCodeStatisticsCollector(ICodeStatCollector collector)
187187
188188 public void Dispose ( )
189189 {
190+ DebugController ? . Dispose ( ) ;
190191 AttachedScriptsFactory . SetInstance ( null ) ;
191192 GlobalsManager . Reset ( ) ;
192193 }
You can’t perform that action at this time.
0 commit comments