Exemplo n.º 1
0
        private void bgTransfer_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (worker.CancellationPending == true) {
                e.Cancel = true;
            } else {
                client = new HFTClientWrapper();
                if (client.ini(true, serverIp, serverPort, serverProgressPort, txtClientFileName.Text, txtServerFileName.Text, 0, "")) {
                    bgTransfer.ReportProgress(100, client.run());
                } else {
                    bgTransfer.ReportProgress(100, -1);
                }
            }
        }
Exemplo n.º 2
0
        private void bgTransfer_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            int result = (int)e.UserState;
            iniResults();

            lstResult.Items.AddRange(client.getMessagesList().ToArray());
            lstResult.TopIndex = lstResult.Items.Count - 1;
            if (result >= 0) {
                MessageBox.Show("¡Enhorabuena! El archivo '" + dlgOpenFile.SafeFileName + "' se ha subido correctamente!",
                    "¡Enhorabuena!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            } else {
                MessageBox.Show(lstResult.Items[lstResult.Items.Count-1].ToString(),
                    "¡Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            client.Dispose();
            client = null;
            btnExaminar.Enabled = true;
            btnUpload.Enabled = true;
            foreach (Control ctrl in grpResult.Controls) {
                if (!ctrl.Equals(lstResult)) ctrl.Enabled = false;
            }
        }