return shb.ToString().ToLower();\r
}\r
\r
- public static TreeHash CalculateTreeHash(FileSystemInfo fileInfo, int blockSize, string algorithm,CancellationToken token,IProgress<HashProgress> progress )\r
+ public static TreeHash CalculateTreeHash(FileSystemInfo fileInfo, int blockSize, string algorithm,byte parallelism,CancellationToken token,IProgress<HashProgress> progress )\r
{\r
if (fileInfo == null)\r
throw new ArgumentNullException("fileInfo");\r
if (fileInfo is DirectoryInfo || !fileInfo.Exists)\r
return TreeHash.Empty;\r
\r
- return CalculateTreeHashAsync(fileInfo, blockSize, algorithm, 1, token, progress);\r
+ return TaskEx.Run(async ()=>await CalculateTreeHashAsync(fileInfo, blockSize, algorithm, parallelism, token, progress)).Result;\r
}\r
\r
/// <summary>\r
Contract.EndContractBlock();\r
\r
var info = FileInfoExtensions.FromPath(filePath);\r
- var hash=CalculateTreeHashAsync(info, blockSize, algorithm, 1,token,progress);\r
+ var hash=TaskEx.Run(async ()=>await CalculateTreeHashAsync(info, blockSize, algorithm, 1,token,progress).ConfigureAwait(false)).Result;\r
return hash;\r
}\r
\r
\r
- public static TreeHash CalculateTreeHashAsync(string filePath, int blockSize, string algorithm, byte parallelism,CancellationToken token,IProgress<HashProgress> progress )\r
+ public static Task<TreeHash> CalculateTreeHashAsync(string filePath, int blockSize, string algorithm, byte parallelism,CancellationToken token,IProgress<HashProgress> progress )\r
{\r
if (filePath== null)\r
throw new ArgumentNullException("filePath");\r
\r
\r
\r
- public static TreeHash CalculateTreeHashAsync(FileSystemInfo info, int blockSize,string algorithm, int parallelism,CancellationToken token,IProgress<HashProgress> progress )\r
+ public static async Task<TreeHash> CalculateTreeHashAsync(FileSystemInfo info, int blockSize,string algorithm, byte parallelism,CancellationToken token,IProgress<HashProgress> progress )\r
{\r
if (info==null)\r
throw new ArgumentNullException("info");\r
//var md5 = new MD5BlockCalculator();\r
//Action<long, byte[], int> postAction = md5.PostBlock;\r
//Calculate the blocks asyncrhonously\r
- var hashes = BlockHashAlgorithms.CalculateBlockHashesInPlacePFor(stream, blockSize, algorithm, parallelism,token, progress).Result;\r
+ var hashes = await BlockHashAlgorithms.CalculateBlockHashesInPlacePFor(stream, blockSize, algorithm, parallelism,token, progress).ConfigureAwait(false);\r
//var hashes = BlockHashAlgorithms.CalculateBlockHashesInPlacePFor(stream, blockSize, algorithm, parallelism, postAction, token, progress).Result; \r
\r
//And then proceed with creating and returning a TreeHash\r