How do I start a task and have it run for a set amount of time?
Use millis();

Record millis() in a long variable like below when the solenoid starts
StartTime = millis();

to switch off solenoid after 60 seconds you may do 

if ( (millis() - StartTime)/1000 ) &gt;  60
{
   // switch off solenoid
}


enjoy coding.

There are other ways as well to achieve this... but this is being easiest  and you don't have to wait caused by using delay();