0

I'm still trying to solve an issue (described in this thread: Dispatcher.BeginInvoke not being executed in one case) where the delegate is not being executed in a certain situation through Dispatcher.BeginInvoke, but works if the method is being called in the same thread.

Working: NotifyEntityChanged(pNotifyEventItem.ToArray())
Not working: Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new HandleEntityChanged(NotifyEntityChanged), pNotifyEventItem.ToArray());

Question: Is there a way to analyze what's going on between the moment BeginInvoke is being called and the moment, the delegate is being executed?

  • Could the instruction be stuck in the execution queue?
  • Could there be a silent exception?
Community
  • 1
  • 1
Philippe
  • 1,949
  • 4
  • 31
  • 57
  • Firing this event and *continuing* to modify the collection in your worker thread is a very questionable practice that's guaranteed to cause trouble. What matters most is what the UI thread is doing, nothing happens if it is busy or stuck in a loop or wait. Use Invoke() instead, now you can troubleshoot deadlock. – Hans Passant Aug 20 '14 at 13:20
  • I'm working on legacy code, this bit has been committed in 2009 and worked fine from what I've been told. Looking at the code comments, it looks like opening pandoras box to do this with Invoke(). We're in the middle of a DB transaction, saving many entities, where the GUI should update itself after the transaction is completed. – Philippe Aug 20 '14 at 13:30

0 Answers0