【发布时间】:2012-09-06 22:34:19
【问题描述】:
假设一台除了运行这个程序什么都不做的计算机有 500 功率。当它运行它时,它会下降到450。当它关闭程序时,它会回到500吗?代码:
bool shouldCheck = true;
string word = "hndxgfhesufyhsukj";
string name = "NAME OF PROGRAM HERE";
bool updates = false;
private void button1_Click(object sender, EventArgs e)
{
if (shouldCheck == true)
{
var url = "MYURL";
var client = new WebClient();
using (var stream = client.OpenRead(url))
using (var reader = new StreamReader(stream))
{
string downloadedString;
while ((downloadedString = reader.ReadLine()) != null)
{
if (downloadedString == word)
{
updates = true;
this.Hide();
Form1 form2 = new Form1();
form2.Show();
MessageBox.Show("There's no updates, and the full program has opened! Enjoy!", name, MessageBoxButtons.OK, MessageBoxIcon.Information);
client.Dispose();
}
else
{
MessageBox.Show("There is an update! Downloading now!", name, MessageBoxButtons.OK, MessageBoxIcon.Information);
url = "MYURL";
var web = new WebBrowser();
web.Navigate(url);
}
}
}
}
}
这运行良好,但程序关闭后会影响性能吗?关闭是指更新已被检查,新表单已打开,并使用红色 X 按钮关闭。
【问题讨论】:
-
@ByronWhitlock - 我想他担心它会超过 9000!
-
我使用 500 功率作为参考,这样我就能明白我的意思了。没有实际的力量。
-
您的“使用”块将正确处理您的对象,释放资源。
-
@chipperyman573:使用绝对没有意义的测量单位是没有帮助的。只需询问应用程序使用的任何资源是否会在退出时被操作系统回收。
-
@everyone - 谁在乎?也许这个可怜的家伙英语不好,我们都明白他在说什么……放手吧。
标签: c# performance