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 に答える