class Program
{
public static bool bStop = false;
static int x = 10;
static void Main(string[] args)
{
//定義線程
Thread LogThread = new Thread(new ThreadStart(DoService));
//設置線程為后台線程,那樣進程里就不會有未關閉的程序了
LogThread.IsBackground = true;
if (bStop == false)
{
LogThread.Start();//起線程
}
Console.ReadKey();
}
private static void DoService()
{
while (true)
{
bStop = false;
SendToService();
System.Threading.Thread.Sleep(1000);//1000=1秒
}
}
private static void SendToService()
{
x++;
Console.WriteLine(x);
}
}
