diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-09-14 11:50:47 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-09-14 11:50:47 +0300 |
| commit | d2341eb3059629ae98ef4d53f341bda6bc84e325 (patch) | |
| tree | 5ff720d091fd077719f6c7da4a1266dd8be074a5 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | 1003204a4968a15cacac015bdd9177109215ed6e (diff) | |
| download | Tango-d2341eb3059629ae98ef4d53f341bda6bc84e325.tar.gz Tango-d2341eb3059629ae98ef4d53f341bda6bc84e325.zip | |
Fixed issue with MS event logger.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs index 613b443df..89b8920d9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs @@ -29,6 +29,7 @@ namespace Tango.MachineStudio.Common.EventLogging public class DefaultEventLogger : ExtendedObject, IEventLogger { private ObservablesContext _db; + private static object _lockInit = new object(); private Thread _logThread; private ConcurrentQueue<MachinesEvent> _events; private IStudioApplicationManager _application; @@ -89,24 +90,27 @@ namespace Tango.MachineStudio.Common.EventLogging private void Init() { - if (!_isInitialized) + lock (_lockInit) { - try + if (!_isInitialized) { - _db = ObservablesContext.CreateDefault(); + try + { + _db = ObservablesContext.CreateDefault(); + + _db.EventTypes.ToList(); - _db.EventTypes.ToList(); + foreach (var type in _db.EventTypes) + { + _eventTypesGuids.Add((EventTypes)type.Code, type); + } - foreach (var type in _db.EventTypes) + _isInitialized = true; + } + catch { - _eventTypesGuids.Add((EventTypes)type.Code, type); + _isInitialized = false; } - - _isInitialized = true; - } - catch - { - _isInitialized = false; } } } @@ -210,6 +214,8 @@ namespace Tango.MachineStudio.Common.EventLogging /// <param name="machineEvent">The machine event.</param> public void Log(MachinesEvent machineEvent) { + Init(); + machineEvent.HostName = _hostName; machineEvent.EventType = _eventTypesGuids[machineEvent.Type]; |
