控制台:
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(delegate()
{
while (true)
{
//int i = 1;
}
});
t.Start();
Console.ReadLine();
}
}
WinForm:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread t = new Thread(delegate() {
while (true) {
Console.WriteLine("Form1_Load");
}
});
t.Start();
}
}问题:为什么两个程序所占用CPU相差这么大?控制台50%左右,WinForm没什么影响?
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(delegate()
{
while (true)
{
//int i = 1;
}
});
t.Start();
Console.ReadLine();
}
}
WinForm:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread t = new Thread(delegate() {
while (true) {
Console.WriteLine("Form1_Load");
}
});
t.Start();
}
}问题:为什么两个程序所占用CPU相差这么大?控制台50%左右,WinForm没什么影响?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货