ble and simulation stop when window closes
This commit is contained in:
@@ -16,6 +16,7 @@ using System.Windows.Shapes;
|
|||||||
using ClientApp.Utils;
|
using ClientApp.Utils;
|
||||||
using Hardware.Simulators;
|
using Hardware.Simulators;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using ProftaakRH;
|
||||||
|
|
||||||
namespace ClientApp
|
namespace ClientApp
|
||||||
{
|
{
|
||||||
@@ -24,31 +25,33 @@ namespace ClientApp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private IHandler handler;
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
Client client = new Client();
|
Client client = new Client();
|
||||||
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new MainWindowViewModel(client);
|
DataContext = new MainWindowViewModel(client);
|
||||||
|
|
||||||
|
|
||||||
//BLEHandler bLEHandler = new BLEHandler(client);
|
//BLEHandler bLEHandler = new BLEHandler(client);
|
||||||
|
|
||||||
//bLEHandler.Connect();
|
//bLEHandler.Connect();
|
||||||
|
|
||||||
//client.setHandler(bLEHandler);
|
//client.setHandler(bLEHandler);
|
||||||
|
|
||||||
|
|
||||||
BikeSimulator bikeSimulator = new BikeSimulator(client);
|
BikeSimulator bikeSimulator = new BikeSimulator(client);
|
||||||
|
|
||||||
Thread newThread = new Thread(new ThreadStart(bikeSimulator.StartSimulation));
|
Thread newThread = new Thread(new ThreadStart(bikeSimulator.StartSimulation));
|
||||||
newThread.Start();
|
newThread.Start();
|
||||||
|
|
||||||
|
|
||||||
client.SetHandler(bikeSimulator);
|
client.SetHandler(bikeSimulator);
|
||||||
|
handler = bikeSimulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnClosed(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnClosed(e);
|
||||||
|
handler.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user