我有一个方法,读取一些文件并获得散列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