I'm using an EDM object along with a dataGridView and bindingSource. After adding many (1000's) of new elements to my binding source/grid, a call to context.SaveChanges from a button click results in the UI hanging for many seconds. I've read that EDM objects are not thread-safe so I don't think I can put this task on a background worker. Does anybody have any tips so that I can inform the user that work is in progress (like marquee progress bar, etc.)?
+1
A:
I've read that EDM objects are not thread-safe so I don't think I can put this task on a background worker.
Sure you can! Not thread-safe means that it's not safe to access the instances from many threads simultaneously. It's completely safe to use a single background worker to do the job.
Diadistis
2010-05-19 20:49:04
A:
If you don't want to hand the UI you need to either make the call on a background thread or use an Asynchronous form of the call. If you make the context.SaveChanges
directly from the button event handler it will hang the UI
Stephan
2010-05-19 20:50:32