我有这样的代码:我该如何更快更高效地做到这一点?
var url = "myurl.com/hwid.txt";
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 == finalHWID)
{
update();
allowedIn = true;
}
}
if (allowedIn == false)
{
MessageBox.Show("You are not allowed into the program!", name,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
这将检查你的HWID对那些允许的列表。但是,每次完成检查时大约需要5-10秒。有没有办法让它变得更快?
你有没有运行,即使最基本的测试,看看什么是最耗时? 'update()'做了什么? –
@EdS。是的,我有。它从网站上阅读需要时间。我应该在问题中提出这个问题,对不起。更新只允许通过删除覆盖整个程序的组来阻止您进行访问。 – Frank
“这是从网站上读取需要时间”---好吧,购买更快的宽带然后 – zerkms