I am currently for the first time in need to rewrite my app into library. I have succes so far, but I need to somehow make auto repeated process, which could be started by simply camShield.start().
But I am not able to reference the enabled from anywhere. The idea here is that I would start thread with timer, which would be checking on the enabled variable. But to do that, I need another function, like stop(), which would set the enabled variable to false.
Is there any better way to implement such a function?
---EDIT----
I need to write functions CamShield.start() and CamShield.stop(), which would be able to access the CamShield.enabled variable.
Here is part of code, where I am trying to solve it (It is Class Library)
using SharpAdbClient;
using System;
using System.Diagnostics;
using System.Threading;
namespace BaReader
{
public class Private
{
public class CamShield
{
internal bool enabled = true;
public static void start()
{
new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
Timer camShieldTimer = new Timer(tap, null, 0, 20000);
}).Start();
}
}
internal static void tap(Object o)
{
AdbClient.Instance.ExecuteRemoteCommand("input tap 600 900", Device.lookup(), null);
Debug.WriteLine("Tapped");
}
}
}
Thanks in advance for any ideas.