I have scenarios for turning toilet fan after 2 minute if toilet light is on. That is my code
When.ModuleParameterChanged( (module, parameter) =>
{
switch (module.Instance.Address)
{
case "D1":
//...
break;
case "D5":
//...
break;
case "A1":
//...
break;
case "A2":
if(parameter.Is("Status.Level") && parameter.Value == "1" && parameter.Statistics.Last.Value == 0)
{
var x10B2 = Modules.InDomain("HomeAutomation.X10").WithAddress("B2");
Thread.Sleep(120000);
x10B2.On();
return false;
}
break;
default:
break;
}
return true;
});
Program.GoBackground();
In this case the program will sleep for 2 minute, how run wait and B2 on async without stopping program?