11using System ;
22using ScriptEngine . Machine . Contexts ;
33using ScriptEngine . Machine ;
4- using System . Reflection ;
4+ using ScriptEngine . HostedScript . Library ;
5+ using System . Collections . Concurrent ;
56
67namespace oscs
78{
@@ -10,11 +11,12 @@ public class OneScriptClientServer : AutoContext<OneScriptClientServer>
1011 {
1112 private static CsCommunicationStates cs_CommunicationStates = new CsCommunicationStates ( ) ;
1213 public static IValue Event = null ;
13- public static ScriptEngine . HostedScript . Library . DelegateAction EventAction = null ;
14- public static System . Collections . ArrayList EventQueue = new System . Collections . ArrayList ( ) ;
14+ public static DelegateAction EventAction = null ;
15+ public static ConcurrentQueue < dynamic > EventQueue = new ConcurrentQueue < dynamic > ( ) ;
1516 public static bool goOn = true ;
16- public static ScriptEngine . HostedScript . Library . DelegateAction ServerMessageReceived ;
17- public static ScriptEngine . HostedScript . Library . DelegateAction ServerMessageSent ;
17+ public static DelegateAction ServerMessageReceived ;
18+ public static DelegateAction ServerMessageSent ;
19+ public static bool thirdPartyClientMode = false ;
1820
1921 [ ScriptConstructor ]
2022 public static IRuntimeContextInstance Constructor ( )
@@ -24,6 +26,13 @@ public static IRuntimeContextInstance Constructor()
2426
2527 public OneScriptClientServer Base_obj ;
2628
29+ [ ContextProperty ( "РежимСтороннегоКлиента" , "ThirdPartyClientMode" ) ]
30+ public bool ThirdPartyClientMode
31+ {
32+ get { return thirdPartyClientMode ; }
33+ set { thirdPartyClientMode = value ; }
34+ }
35+
2736 [ ContextProperty ( "АргументыСобытия" , "EventArgs" ) ]
2837 public IValue EventArgs
2938 {
@@ -72,17 +81,17 @@ public ScriptEngine.HostedScript.Library.DelegateAction DoEvents()
7281 {
7382 while ( EventQueue . Count == 0 )
7483 {
75- System . Threading . Thread . Sleep ( 10 ) ;
84+ System . Threading . Thread . Sleep ( 7 ) ;
7685 }
7786 return EventHandling ( ) ;
7887 }
7988
8089 public static ScriptEngine . HostedScript . Library . DelegateAction EventHandling ( )
8190 {
82- dynamic EventArgs1 = ( dynamic ) EventQueue [ 0 ] ;
91+ dynamic EventArgs1 ;
92+ EventQueue . TryDequeue ( out EventArgs1 ) ;
8393 Event = EventArgs1 . dll_obj ;
8494 EventAction = EventArgs1 . EventAction ;
85- EventQueue . RemoveAt ( 0 ) ;
8695 return EventAction ;
8796 }
8897
0 commit comments