VoteAsync() public static method

public static VoteAsync ( string host, int port, CookieCollection cookieCollection, System.Guid electionId, System.Numerics.BigInteger encryptedVector ) : System.Threading.Tasks.Task
host string
port int
cookieCollection System.Net.CookieCollection
electionId System.Guid
encryptedVector System.Numerics.BigInteger
return System.Threading.Tasks.Task
示例#1
0
        private static void Vote(string host, KeyValuePair <User, int[]>[] voters, Guid id, PublicKey publicKey)
        {
            log.Info("Voting in parallel...");
            var candidateTasks = voters.Select(kvp => ElectroClient.VoteAsync(host, Program.PORT, kvp.Key.Cookies, id, HomoCrypto.EncryptVector(kvp.Value, publicKey))).ToArray();

            try
            {
                Task.WaitAll();
                log.InfoFormat("Voted by {0} users", voters.Length);
            }
            catch (Exception e)
            {
                throw new ServiceException(ExitCode.DOWN, string.Format("Failed to vote by {0} users in parallel: {1}", candidateTasks.Length, e));
            }
        }