Пример #1
0
 void m_backgroudWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     //if (e.Cancelled)
     //{
     //  MessageBox.Show("Canceled");
     // Debug.Write("canceled......");
     // }//throw new NotImplementedException();
     if (waitFrm != null)
     {
         waitFrm.Dispose();
         waitFrm.Close();
         waitFrm = null;
     }
 }
Пример #2
0
        private void uploadBtn_Click(object sender, EventArgs e)
        {
            if (recordListBox.SelectedIndex == -1)
            {
                MessageBox.Show("请选中需要上传的录音文件!");
                return;
            }
            m_backgroudWorker.RunWorkerAsync();
            fileName = recordListBox.SelectedItem.ToString();
            waitFrm  = new UploadWaitFrm();
            waitFrm.ShowDialog();

            /*string url = "http://localhost:58622/uploadFile.ashx";
             *
             * //string path = "D:\\vs_git\\123.mp3";
             * string fileName = recordListBox.SelectedItem.ToString();
             * string path = pList[fileName];
             * try
             * {
             *  //开始执行后台任务
             *  m_backgroudWorker.RunWorkerAsync();
             *  string msg = Utils.uploadFile(fileName,path, url);
             *  UploadFileResult result=JavaScriptConvert.DeserializeObject<UploadFileResult>(msg);
             *  m_backgroudWorker.CancelAsync();
             *  if (result.Result == true)
             *  {
             *       //m_backgroudWorker.CancelAsync();
             *      MessageBox.Show("上传成功!!!");
             *
             *  }
             *  else
             *  {
             *      MessageBox.Show("上传失败!错误信息为:"+result.Msg);
             *
             *  }
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show("上传失败,发生错误:"+ex.Message);
             *  m_backgroudWorker.CancelAsync();
             * }
             */
        }