aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2020-09-15 09:46:12 +0300
committerAvi Levkovich <avi@twine-s.com>2020-09-15 09:46:12 +0300
commitb0d3ccdbb8cd825c32a1f616223c9c391e0d1e14 (patch)
tree11ed48b45b15191f8985b8e9696b1808e218f7eb /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging
parent3218bd4b12197f5b27147788221f738254dec41f (diff)
parentc502b0a93c9a5365bbdd834e027e02446b3b4210 (diff)
downloadTango-b0d3ccdbb8cd825c32a1f616223c9c391e0d1e14.tar.gz
Tango-b0d3ccdbb8cd825c32a1f616223c9c391e0d1e14.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs30
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];