private delegate void UpdateListBoxDelegate(DataSet ds); void UpdateListBox(DataSet ds) { if (this.Dispatcher.Thread != System.Threading.Thread.CurrentThread) { UpdateListBoxDelegate updateListBox = new UpdateListBoxDelegate(this.UpdateListBox); this.Dispatcher.Invoke(DispatcherPriority.Normal, updateListBox, ds); } else { // Write Operate Code Here } }
Related:
http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.checkaccess.aspx
http://marxbrain.spaces.live.com/blog/cns!86859239207B1F38!617.entry
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/60164e9e-1d2a-46af-a60f-6606be7592cb