private void Decipher()
        {
            if (this.votingList.SelectedIndices.Count > 0)
              {
            this.run = true;
            SetGuiEnable(false);

            ListViewItem item = this.votingList.SelectedItems[0];
            VotingDescriptor voting = (VotingDescriptor)item.Tag;

            string fileName = string.Format("{0}@{1}.pi-auth", Status.Certificate.Id.ToString(), voting.Id.ToString());
            string filePath = Path.Combine(Status.DataPath, fileName);

            if (File.Exists(filePath))
            {
              OnUpdateWizard();

              if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(Status.Certificate, GuiResources.UnlockActionAuthorityDecipher))
              {
            this.askForPartiallyDecipherCallBackState = AskForPartiallyDecipherCallBackState.Before;

            Status.VotingClient.CreateDeciphers(voting.Id, (AuthorityCertificate)Status.Certificate, filePath, AskForPartiallyDecipherCallBack, CreateDeciphersCompleteCallBack);

            while (this.run)
            {
              if (this.askForPartiallyDecipherCallBackState == AskForPartiallyDecipherCallBackState.During)
              {
                this.askForPartiallyDecipherCallBackResult =
                  MessageForm.Show(
                  string.Format(GuiResources.AskForPartiallyDecipher, this.askForPartiallyDecipherValidBallots),
                  GuiResources.MessageBoxTitle,
                  MessageBoxButtons.YesNo,
                  MessageBoxIcon.Question,
                  DialogResult.No)
                  == DialogResult.Yes;

                this.askForPartiallyDecipherCallBackState = AskForPartiallyDecipherCallBackState.After;
              }

              Status.UpdateProgress();
              Thread.Sleep(10);
            }

            Status.UpdateProgress();

            if (this.exception == null)
            {
              item.Tag = this.votingDescriptor;
              item.SubItems[0].Text = this.votingDescriptor.Status.Text();
              item.SubItems[5].Text =
                this.votingDescriptor.Status == VotingStatus.New ||
                this.votingDescriptor.Status == VotingStatus.Sharing ||
                this.votingDescriptor.Status == VotingStatus.Deciphering ?
                this.votingDescriptor.AuthoritiesDone.Count().ToString() + " / " + this.votingDescriptor.AuthorityCount.ToString() :
                string.Empty;
              votingList_SelectedIndexChanged(this.votingList, new EventArgs());

              Status.SetMessage(Resources.AuthorityDecipherDone, MessageType.Success);
            }
            else
            {
              Status.SetMessage(this.exception.Message, MessageType.Error);
            }

            Status.Certificate.Lock();
              }
              else
              {
            Status.SetMessage(Resources.AuthorityDecipherCanceled, MessageType.Info);
              }
            }
            else
            {
              Status.SetMessage(Resources.CreateVotingAuthFileMissing, MessageType.Error);
            }

            SetGuiEnable(true);
              }
        }
        private bool AskForPartiallyDecipherCallBack(int validEnvelopeCount)
        {
            this.askForPartiallyDecipherValidBallots = validEnvelopeCount;
              this.askForPartiallyDecipherCallBackState = AskForPartiallyDecipherCallBackState.During;

              while (this.askForPartiallyDecipherCallBackState == AskForPartiallyDecipherCallBackState.During)
              {
            Thread.Sleep(10);
              }

              return this.askForPartiallyDecipherCallBackResult;
        }