Package updates, added test server
[pithos-ms-client] / trunk / Pithos.Network / Signature.cs
index 748092a..e3281db 100644 (file)
@@ -77,7 +77,7 @@ namespace Pithos.Network
             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
@@ -92,7 +92,7 @@ namespace Pithos.Network
             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
@@ -113,12 +113,12 @@ namespace Pithos.Network
             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
@@ -134,7 +134,7 @@ namespace Pithos.Network
 \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
@@ -168,7 +168,7 @@ namespace Pithos.Network
                 //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