Torino is a dotnet controller library for Tor. With it you can use Tor's control protocol to script against the Tor process.
using(var control = new TorController())
{
await control.AuthenticateAsync("pwd");
var version = await control.GetVersionAsync();
var user = await control.GetUserAsync();
Console.WriteLine($"Tor version: {version}");
Console.WriteLine($"Tor user : {user}");
}
using(var control = new TorController())
{
await control.AuthenticateAsync("pwd");
await control.AddEventHandlerAsync(AsyncEvent.BW,
(sender, e) => Console.WriteLine($"[EVENT] {e.Event} -> {e.Line}"));
await control.SignalAsync(Signal.DORMANT);
Console.WriteLine("Time to sleep");
await Task.Delay(5_000);
Console.WriteLine("Waking up");
await control.SignalAsync(Signal.ACTIVE);
await Task.Delay(3_000);
}
using(var control = new TorController())
{
await control.AuthenticateAsync("pwd");
await control.SignalAsync(Signal.SHUTDOWN);
}