There is the following code
public class MyWindow: Window { private delegate void SomeDelegate(); private void SomeMethod() { SomeControl.DoAnything(); } private void SomeMethodAsync() { var d = new SomeDelegate(SomeMethod); d.BeginInvoke(null, null); } }
By itself, I can not access the control from another thread. therefore
SomeControl.DoAnything();
need to wrap in
Dispatcher.BeginInvoke(new ThreadStart(delegate { SomeControl.DoAnything(); }));
But this is redundant if I call SomeMethod()
directly. What is better to do in this case?