コード例 #1
0
        private async void BtnStart_Click(object sender, EventArgs e)
        {
            Button thisButton = sender as Button;

            thisButton.Enabled   = false;
            BtnClose.Enabled     = false;
            BtnSelecFile.Enabled = false;
            try
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                addrList.Clear();
                addrList.dev.BeginLoadData();
                addrList.dev.ReadXml(textBoxPath.Text);
                addrList.dev.EndLoadData();
                stopwatch.Stop();
                //DebugLog.TraceMessage(string.Format("done: {0}", stopwatch.Elapsed));
                var progressIndicator = new Progress <int>(ReportProgress);
                await ICMDBContext.AddDevicesAsync(addrList, progressIndicator);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "操作错误",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            thisButton.Enabled   = true;
            BtnClose.Enabled     = true;
            BtnSelecFile.Enabled = true;
            this.Close();
        }