@@ -32,6 +32,8 @@ namespace net.r_eg.vsSBE.Actions
3232 /// </summary>
3333 public class Binder
3434 {
35+ private static readonly SemaphoreSlim semsync = new ( initialCount : 1 , maxCount : 1 ) ;
36+
3537 internal readonly CancelBuildState buildState = new CancelBuildState ( ) ;
3638
3739 /// <summary>
@@ -47,7 +49,6 @@ public class Binder
4749
4850 protected ISobaCLoader cLoader ;
4951
50- private readonly object sync = new object ( ) ;
5152 private readonly object _plock = new object ( ) ;
5253
5354 /// <summary>
@@ -143,7 +144,7 @@ public int bindPost(int fSucceeded, int fModified, int fCancelCommand)
143144 Status . _ . add ( SolutionEventType . Post , StatusType . Success ) ;
144145 }
145146 catch ( Exception ex ) {
146- Log . Error ( $ "[{ SolutionEventType . Post } ] error: { ex . Message } ") ;
147+ Log . Error ( $ "[{ SolutionEventType . Post } ] error: { ex . Message } ", new ExecLocator ( item , SolutionEventType . Post ) ) ;
147148 Log . Debug ( ex . StackTrace ) ;
148149 Status . _ . add ( SolutionEventType . Post , StatusType . Fail ) ;
149150 }
@@ -224,7 +225,7 @@ public int bindCancel()
224225 Status . _ . add ( SolutionEventType . Cancel , StatusType . Success ) ;
225226 }
226227 catch ( Exception ex ) {
227- Log . Error ( $ "[{ SolutionEventType . Cancel } ] error: { ex . Message } ") ;
228+ Log . Error ( $ "[{ SolutionEventType . Cancel } ] error: { ex . Message } ", new ExecLocator ( item , SolutionEventType . Cancel ) ) ;
228229 Log . Debug ( ex . StackTrace ) ;
229230 Status . _ . add ( SolutionEventType . Cancel , StatusType . Fail ) ;
230231 }
@@ -299,7 +300,7 @@ public void bindBuildRaw(string data, string guid, string item = null)
299300 }
300301 }
301302 catch ( Exception ex ) {
302- Log . Error ( $ "[{ SolutionEventType . Transmitter } ] error: { ex . Message } ") ;
303+ Log . Error ( $ "[{ SolutionEventType . Transmitter } ] error: { ex . Message } ", new ExecLocator ( evt , SolutionEventType . Transmitter ) ) ;
303304 Log . Debug ( ex . StackTrace ) ;
304305 }
305306 }
@@ -401,14 +402,15 @@ protected int sbeEW(ISolutionEventEW evt, Receiver.Output.EWType type)
401402 return Codes . Success ;
402403 }
403404
405+ SolutionEventType setype = ( type == Receiver . Output . EWType . Warnings ) ? SolutionEventType . Warnings : SolutionEventType . Errors ;
404406 try {
405- if ( Cmd . exec ( evt , ( type == Receiver . Output . EWType . Warnings ) ? SolutionEventType . Warnings : SolutionEventType . Errors ) ) {
407+ if ( Cmd . exec ( evt , setype ) ) {
406408 Log . Info ( $ "[{ type } ] finished '{ evt . Name } '") ;
407409 }
408410 return Codes . Success ;
409411 }
410412 catch ( Exception ex ) {
411- Log . Error ( $ "[{ type } ] error: { ex . Message } ") ;
413+ Log . Error ( $ "[{ type } ] error: { ex . Message } ", new ExecLocator ( evt , setype ) ) ;
412414 Log . Debug ( ex . StackTrace ) ;
413415 }
414416 return Codes . Failed ;
@@ -439,7 +441,7 @@ protected int sbeOutput(ISolutionEventOWP evt, ref string raw, string guid, stri
439441 return Codes . Success ;
440442 }
441443 catch ( Exception ex ) {
442- Log . Error ( $ "[{ SolutionEventType . OWP } ] error: { ex . Message } ") ;
444+ Log . Error ( $ "[{ SolutionEventType . OWP } ] error: { ex . Message } ", new ExecLocator ( evt , SolutionEventType . OWP ) ) ;
443445 Log . Debug ( ex . StackTrace ) ;
444446 }
445447 return Codes . Failed ;
@@ -520,7 +522,7 @@ protected void commandEvent(ICommandEvent item)
520522 Status . _ . add ( SolutionEventType . CommandEvent , StatusType . Success ) ;
521523 }
522524 catch ( Exception ex ) {
523- Log . Error ( $ "[{ SolutionEventType . CommandEvent } ] error: { ex . Message } ") ;
525+ Log . Error ( $ "[{ SolutionEventType . CommandEvent } ] error: { ex . Message } ", new ExecLocator ( item , SolutionEventType . CommandEvent ) ) ;
524526 Log . Debug ( ex . StackTrace ) ;
525527 }
526528 Status . _ . add ( SolutionEventType . CommandEvent , StatusType . Fail ) ;
@@ -546,7 +548,7 @@ protected int bindSln(SBEEvent[] evt, SolutionEventType type)
546548 Status . _ . add ( type , StatusType . Success ) ;
547549 }
548550 catch ( Exception ex ) {
549- Log . Error ( $ "[{ typeString } ] error: { ex . Message } ") ;
551+ Log . Error ( $ "[{ typeString } ] error: { ex . Message } ", new ExecLocator ( item , SolutionEventType . SlnOpened ) ) ;
550552 Log . Debug ( ex . StackTrace ) ;
551553 Status . _ . add ( type , StatusType . Fail ) ;
552554 }
@@ -567,7 +569,7 @@ protected int execPre(SBEEvent evt)
567569 return Codes . Success ;
568570 }
569571 catch ( Exception ex ) {
570- Log . Error ( $ "[{ SolutionEventType . Pre } ] error: { ex . Message } ") ;
572+ Log . Error ( $ "[{ SolutionEventType . Pre } ] error: { ex . Message } ", new ExecLocator ( evt , SolutionEventType . Pre ) ) ;
571573 Log . Debug ( ex . StackTrace ) ;
572574 }
573575 return Codes . Failed ;
@@ -801,17 +803,23 @@ protected bool hasExecutionOrder(ISolutionEvent evt)
801803
802804 protected void attachLoggingEvent ( )
803805 {
804- lock ( sync ) {
806+ semsync . Wait ( ) ;
807+ try
808+ {
805809 detachLoggingEvent ( ) ;
806810 Log . _ . Received += onLogging ;
807811 }
812+ finally
813+ {
814+ semsync . Release ( ) ;
815+ }
808816 }
809817
810818 protected void detachLoggingEvent ( )
811819 {
812820 Log . _ . Received -= onLogging ;
813821 }
814-
822+
815823 /// <summary>
816824 /// Works with all processes of internal logging.
817825 /// </summary>
@@ -836,13 +844,15 @@ private void onLogging(object sender, MessageArgs e)
836844 return ;
837845 }
838846
847+ //FIXME
839848 ( new Task ( ( ) =>
840849 {
841850 if ( Thread . CurrentThread . Name == null ) {
842851 Thread . CurrentThread . Name = LoggingEvent . IDENT_TH ;
843852 }
844853
845- lock ( sync )
854+ semsync . Wait ( ) ;
855+ try
846856 {
847857 var ld = cLoader . GetComponent ( typeof ( OwpComponent ) ) as ILogInfo ;
848858 ld ? . UpdateLogInfo ( e . Message , e . Level ) ;
@@ -861,11 +871,12 @@ private void onLogging(object sender, MessageArgs e)
861871 }
862872 }
863873 catch ( Exception ex ) {
864- Log . Error ( $ "[{ SolutionEventType . Logging } ] error: { ex . Message } ") ;
874+ Log . Error ( $ "[{ SolutionEventType . Logging } ] error: { ex . Message } ", new ExecLocator ( evt , SolutionEventType . Logging ) ) ;
865875 Log . Debug ( ex . StackTrace ) ;
866876 }
867877 }
868878 }
879+ finally { semsync . Release ( ) ; }
869880
870881 } ) ) . Start ( ) ;
871882 }
0 commit comments