diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-09-14 13:48:21 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-09-14 13:48:21 +0300 |
| commit | 13afc37417c9281f5fbaacd174fd151d793151eb (patch) | |
| tree | 715e299dc46807ed05c413f6a29f2d7d101c3e46 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | 89ffc630471605c4757b5854af3d73b5b75e98d6 (diff) | |
| parent | 7151024a77daca3a9f37b6bdedc655693ef2f629 (diff) | |
| download | Tango-13afc37417c9281f5fbaacd174fd151d793151eb.tar.gz Tango-13afc37417c9281f5fbaacd174fd151d793151eb.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs | 28 |
1 files changed, 16 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 4da1121b7..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; } } } |
