我有一個方法,讀取一些文件並獲得散列SHA1Managed,然後將其與列表中的其他散列進行比較,如何在其他線程上執行此方法?在其他線程的C#執行方法
public bool CheckFile(string file, string filehash)
{
if (File.Exists(file))
{
using (FileStream stream = File.OpenRead(file))
{
SHA1Managed sha = new SHA1Managed();
byte[] checksum = sha.ComputeHash(stream);
string sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
return sendCheckSum.ToLower() == filehash;
}
}
else return false;
}
另一個線程在哪裏? – Krease
也許你可以使用這個職位的委託:http://stackoverflow.com/questions/811224/how-to-create-a-thread – rivanov
我不認爲你瞭解我的傢伙,我需要一種方式來運行這種方法異步!現在,它阻止了我的用戶界面! – MozzieMD