diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-09-14 10:01:13 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-09-14 10:01:13 +0300 |
| commit | bfeb0128f931f1a122d00d0fdb2e4a3b8d1ac353 (patch) | |
| tree | 11b309037832813459a313b07109ad3e7160cb05 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | |
| parent | 57800c7c60ca335463a54abf148049615fc51c59 (diff) | |
| parent | 56f4fcc504a5a60bb59e48b010aad85f75c4648e (diff) | |
| download | Tango-bfeb0128f931f1a122d00d0fdb2e4a3b8d1ac353.tar.gz Tango-bfeb0128f931f1a122d00d0fdb2e4a3b8d1ac353.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 4205e5246..8f5c67f96 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -41,6 +41,7 @@ using RealTimeGraphX.WPF; using Tango.Core.ExtensionMethods; using System.Diagnostics; using Tango.BL.Builders; +using Tango.Core; namespace Tango.MachineStudio.Technician.ViewModels { @@ -83,6 +84,9 @@ namespace Tango.MachineStudio.Technician.ViewModels private DateTime _diagnosticsStartTime; private DateTime _diagnosticsNowTime; + private ProducerConsumerQueue<StartDiagnosticsResponse> _framesQueue; + private Thread _populateFramesThread; + #region Properties private ObservableCollection<MachineTechTabVM> _tabs; @@ -314,6 +318,8 @@ namespace Tango.MachineStudio.Technician.ViewModels /// <param name="notificationProvider">The notification provider.</param> public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IEventLogger eventLogger) { + _framesQueue = new ProducerConsumerQueue<StartDiagnosticsResponse>(); + Tabs = new ObservableCollection<MachineTechTabVM>(); Tabs.Add(new MachineTechTabVM() { IsSelected = true, Name = "Untitled" }); SelectedTab = Tabs.First(); @@ -448,13 +454,22 @@ namespace Tango.MachineStudio.Technician.ViewModels /// <param name="response">The response.</param> private void DiagnosticsFrameProvider_FrameReceived(object sender, StartDiagnosticsResponse response) { - PopulateDiagnosticsData(response); + _framesQueue.BlockEnqueue(response); } #endregion #region Populate Diagnostics Data + private void PopulateFramesThreadMethod() + { + while (!ApplicationManager.IsShuttingDown) + { + var frame = _framesQueue.BlockDequeue(); + PopulateDiagnosticsData(frame); + } + } + /// <summary> /// Populates the diagnostics data to the proper elements. /// </summary> @@ -2308,7 +2323,12 @@ namespace Tango.MachineStudio.Technician.ViewModels public override void OnApplicationReady() { - + if (_populateFramesThread == null) + { + _populateFramesThread = new Thread(PopulateFramesThreadMethod); + _populateFramesThread.IsBackground = true; + _populateFramesThread.Start(); + } } #endregion |
