mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-12 10:53:57 +00:00
43 lines
939 B
C#
43 lines
939 B
C#
using System;
|
|
using System.Threading;
|
|
using Xamarin.Forms;
|
|
using SharpOSC;
|
|
namespace qController
|
|
{
|
|
public class QUpdater
|
|
{
|
|
|
|
private bool active = true;
|
|
private QController qController;
|
|
private Thread updateThread;
|
|
public QUpdater(QController controller)
|
|
{
|
|
qController = controller;
|
|
updateThread = new Thread(new ThreadStart(UpdateLoop));
|
|
}
|
|
|
|
public void Start(){
|
|
updateThread.Start();
|
|
}
|
|
|
|
public void UpdateLoop()
|
|
{
|
|
active = true;
|
|
Device.StartTimer(TimeSpan.FromSeconds(5.0), () => {
|
|
SendThump();
|
|
return active;
|
|
});
|
|
}
|
|
|
|
public void SendThump()
|
|
{
|
|
qController.qClient.sendStringUDP("/thump");
|
|
}
|
|
|
|
public void Kill(){
|
|
active = false;
|
|
updateThread.Abort();
|
|
}
|
|
}
|
|
}
|