HomeGenie Forum
General Category => General Discussion => Topic started by: LotusV on May 09, 2016, 04:56:01 PM
-
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?
-
Ok, I found solution.
Program.RunAsyncTask(()=>{
if(parameter.Is("Status.Level") && parameter.Value == "1" && parameter.Statistics.Last.Value == 0)
{
Pause(2);
var x10B1 = Modules.InDomain("HomeAutomation.X10").WithAddress("B1");
//Thread.Sleep(120000);
x10B1.On();
}
});