public voID bw_Convert_DoWork(object sender,DoWorkEventArgs e) { e.Result = e.Argument; for (int i = 0; i < ftable.Rows.Count; i++) { try { sqlCommand cmd = new sqlCommand("INSERT INTO TBL_CDR_ANALYZER (LNG_UPLOAD_ID,DAT_START,LNG_DURATION,INT_DIRECTION,INT_CALL_DATA_TYPE,\n" + "TXT_TARGET_NUMBER,TXT_OTHER_PARTY_NUMBER,TXT_TARGET_imsI,TXT_TARGET_IMEI,TXT_TARGET_CELL_ID,TXT_ROAMING_NETWORK_COMPANY_name) VALUES \n" + "(@UPLOAD_ID,@START_DATE,@DURATION,@DIRECTION,@CALL_TYPE,@TARGET_NUMBER,@OTHER_PARTY_NUMBER,@imsI,@IMEI,@CELL_ID,@ROAMING_name)",sqlCon); cmd.Parameters.Add("@UPLOAD_ID",sqlDbType.Int).Value = 1; cmd.Parameters.Add("@START_DATE",sqlDbType.DateTime).Value = ftable.Rows[i]["CallDate"]; cmd.Parameters.Add("@DURATION",sqlDbType.Int).Value = ftable.Rows[i]["CallDuration"]; cmd.Parameters.Add("@DIRECTION",sqlDbType.Int).Value = GetCallDirection(ftable.Rows[i]["CallDirection"].ToString()); cmd.Parameters.Add("@CALL_TYPE",sqlDbType.Int).Value = GetCallType(ftable.Rows[i]["CallType"].ToString()); cmd.Parameters.Add("@TARGET_NUMBER",sqlDbType.VarChar,25).Value = ftable.Rows[i]["TargetNo"]; cmd.Parameters.Add("@OTHER_PARTY_NUMBER",25).Value = ftable.Rows[i]["OtherPartyNo"]; cmd.Parameters.Add("@imsI",50).Value = ftable.Rows[i]["imsI"]; cmd.Parameters.Add("@IMEI",50).Value = ftable.Rows[i]["IMEI"]; cmd.Parameters.Add("@CELL_ID",50).Value = ftable.Rows[i]["CellID"]; cmd.Parameters.Add("@ROAMING_name",sqlDbType.NVarChar,255).Value = ftable.Rows[i]["RoamingCompany"]; sqlCon.open(); cmd.ExecuteNonquery(); sqlCon.Close(); } catch (sqlException ex) { } finally { sqlCon.Close(); } bw_Convert.ReportProgress((100 * i) / ftable.Rows.Count); **Label1.Text = i.ToString() + "files Converted";** // getting error Here. } }
如何在这里更新Label1文本?
解决方法 这应该可以从后台线程更改GUI.Label1.Invoke((MethodInvoker)delegate { Label1.Text = i.ToString() + "files Converted";});总结
以上是内存溢出为你收集整理的c# – 更新背景工作者winforms中的标签文本全部内容,希望文章能够帮你解决c# – 更新背景工作者winforms中的标签文本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)