mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-22 15:39:19 +00:00
Move updater to its own thread
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using SharpOSC;
|
using SharpOSC;
|
||||||
namespace qController
|
namespace qController
|
||||||
@@ -7,20 +8,25 @@ namespace qController
|
|||||||
{
|
{
|
||||||
private bool active = true;
|
private bool active = true;
|
||||||
private QController qController;
|
private QController qController;
|
||||||
|
private Thread updateThread;
|
||||||
public QUpdater(QController controller)
|
public QUpdater(QController controller)
|
||||||
{
|
{
|
||||||
qController = controller;
|
qController = controller;
|
||||||
|
updateThread = new Thread(new ThreadStart(UpdateLoop));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(){
|
public void Start(){
|
||||||
|
updateThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateLoop()
|
||||||
|
{
|
||||||
active = true;
|
active = true;
|
||||||
Device.StartTimer(TimeSpan.FromSeconds(0.01), () => {
|
Device.StartTimer(TimeSpan.FromSeconds(0.01), () => {
|
||||||
//qController.sendCommandUDP("/selectedCues");
|
|
||||||
UpdateSelected();
|
UpdateSelected();
|
||||||
UpdateLevels();
|
UpdateLevels();
|
||||||
return active;
|
return active;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSelected()
|
public void UpdateSelected()
|
||||||
@@ -35,6 +41,7 @@ namespace qController
|
|||||||
|
|
||||||
public void Kill(){
|
public void Kill(){
|
||||||
active = false;
|
active = false;
|
||||||
|
updateThread.Abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user