我有这段代码:
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秒。有没有办法让它变得更快?
答案 0 :(得分:2)
找到匹配后你可以break
:
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;
break;
}
}
}
if (allowedIn == false)
{
MessageBox.Show("You are not allowed into the program!", name, MessageBoxButtons.OK, MessageBoxIcon.Error);
}