I have an application with the following code in my main function:
var timer = new System.Threading.Timer(Callback_f, null,
TimeSpan.Zero, TimeSpan.FromMinutes(srcInterval));
Okay this actually works but ONLY when I put something to keep my application alive like console.readkey()
or an infinite while loop:
while (true)
{
}.
The infinite loop is not an option for me as it is too time consuming. The thing is I can not use the console.readkey
function either because it's a Windows.forms application with no forms in it. (i.e. when I run it as a console application and put a console.readkey()
method at the end it works. However I want to avoid the showing of the black window, it's an application with no interface which runs in the background). Any suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…