❔ updating a DGV from another form on another thread
hi all,
I'm wondering if you can help me with an issue I'm having updating a DGV.
I'm getting a thread operation error as below:
Cross-Thread operation not valid: Control 'dvgUSBDongles' accessed from a thread other than the thread it was created on
Now I understand why I'm getting this and its because the form I'm trying to access it on was generated from a BackgroundWorker(so on a seperate thread) but im not too clued up on this currently and am unsure how to fix it. Everything ive done so far ive managed to do from from alot of googling. but threads/threading is just meh!!!!
this is my code:
6 Replies
you need to invoke it on the mainforms thread
any examples?
ok thank you, il play about some more
ok i think i possibly undertand, where i have my form loading like so
i should of
this in turn pushes the form back to the primary thread
please correct me if im wrong
thanks @pobiega
uh, maybe? Im not sure how it works with opening new windows, but probably
the thing with Invoke is that it schedules the action you pass to run on the UI thread owned by the thing you call
Invoke
onWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.