1

我有这个代码:

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 秒。有没有办法让它跑得更快?

4

1 回答 1

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);
}
于 2012-09-27T23:56:37.830 回答