Do I need to synchronize calls with Dispatcher.Invoke when accessing multiple background threads?
I know Dispatcher.BeginInvoke will automatically synchronize calls for the silverlight application ( http://msdn.microsoft.com/en-us/library/z8chs7ft(v=vs.95).aspx )
This is also true for the wpf application or should I uncomment the lock statement below.
public MainWindow() { InitializeComponent(); Dispatcher.BeginInvoke(new Action(() => { const int MAX_NR_THREADS = 1000; for (int i = 0; i < MAX_NR_THREADS; ++i) { int j = i+1; new Thread(()=>ThreadMethod(j)).Start(); } })); } private void ThreadMethod(int threadId) { const int ONE_MILLION = 1000000; for (int i = 0; i < ONE_MILLION/threadId; ++i) {
source share