c# - DataGridView default error inside a new thread -
really don't know if doing right programmatically or not hope point me out. have datagridview c# showing info linked mysql database , input boxes help inserting info database , goes alright, when decided create inserting operation in separate new thread next within add together button:
private void addtoolstripmenuitem_click(object sender, eventargs e){ try{ new thread(() =>{ // insertion code goes here //to update datagridview after inserting this.studentinfotableadapter.fill(this.schooldataset.studentinfo); }).start(); }catch(exception ex){...} }
so new dialog error popping-up in each new insert operation , nil saved, here error:
i thought error maybe caused of this
conflicting in this.studentinfotableadapter.fill(this.schooldataset.studentinfo);
did right error still there. suggestion help me out , appreciated.
finally i've got it, after hours of searching, reading, , trying found should utilize invoke
specific line within thread this.studentinfotableadapter.fill(this.schooldataset.studentinfo);
so becomes following:this.invoke(new methodinvoker(delegate { this.studentinfotableadapter.fill(this.schooldataset.studentinfo);}));
i think error caused because line calls features main thread update datagridview while new thread executing , programmatically there exists cross-thread operation exception
modifying or editing gui prevented except main thread error arises thread behavior! it's how did understand that. if i'm wrong please point me.
c# mysql datagridview
No comments:
Post a Comment