-2

I have this line in my backgroundWorker thread:

Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => this.Network.Nodes.Add(node))).Wait();

I'm getting an exception InvalidOperationException from it.

Yogevnn
  • 1,430
  • 2
  • 18
  • 37

1 Answers1

0

I would imagine that

BeginInvoke(...).Wait()

would deadlock if you are currently on the UI thread. Try using Invoke instead.

Ventsyslav Raikov
  • 6,882
  • 1
  • 25
  • 28