64 lines
930 B
C#
64 lines
930 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace charger_gui.operations
|
|
{
|
|
class AutomaticOperation
|
|
{
|
|
|
|
private Thread workingThread;
|
|
|
|
public bool IsComplete
|
|
{
|
|
get
|
|
{
|
|
return workingThread == null || workingThread.IsAlive;
|
|
}
|
|
}
|
|
|
|
public event Action StatusChanged;
|
|
public virtual string Status
|
|
{
|
|
get
|
|
{
|
|
return "UNKNOWN";
|
|
}
|
|
}
|
|
|
|
protected Logger log;
|
|
protected MainWindowViewModel model;
|
|
|
|
public AutomaticOperation(Logger log, MainWindowViewModel model)
|
|
{
|
|
this.log = log;
|
|
this.model = model;
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
workingThread = new Thread(Work);
|
|
workingThread.Start();
|
|
}
|
|
|
|
public void Cancel()
|
|
{
|
|
if (workingThread != null)
|
|
{
|
|
workingThread.Abort();
|
|
}
|
|
}
|
|
|
|
protected void OnStatusChanged()
|
|
{
|
|
StatusChanged?.Invoke();
|
|
}
|
|
|
|
protected virtual void Work()
|
|
{
|
|
}
|
|
}
|
|
}
|