Tech_Men
asked on
function that i need to run every 1 min in win form app
hi there ,
i need to make a call to db every 1 min
i try to do this :
how can i fix this that its will work every min
whit out frees my app
thanks ...
i need to make a call to db every 1 min
i try to do this :
private static void GetLids()
{
var timer = new System.Threading.Timer(
s => GetLidsFromSsd(),
null,
TimeSpan.Zero,
TimeSpan.FromMinutes(1));
MessageBox.Show(DateTime.Now.ToString());
}
private static void GetLidsFromSsd()
{
EfLids.GetLidsFromApi();
}
i call this func in FormLoad but its run only 1 time when the app first open how can i fix this that its will work every min
whit out frees my app
thanks ...
set AutoReset to true and try again
or define timer as a public var and call timer.start after db call
var timer System.Threading.Timer;
private static void GetLids()
{
timer = new System.Threading.Timer(
s => GetLidsFromSsd(),
null,
TimeSpan.Zero,
TimeSpan.FromMinutes(1));
}
private static void GetLidsFromSsd()
{
EfLids.GetLidsFromApi();
timer.start();
}
ASKER
var timer System.Threading.Timer; its not legal in c# and i don't see the option start in timer
please answer only if you know ...
thanks
please answer only if you know ...
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
very nice thanks...
var timer System.Threading.Timer; its not legal in c# and i don't see the option start in timer
please answer only if you know ...
that was your code!!!...
if you dont know how to to write code, then first learn how to write code before asking...