While doing some forensics archeological survey in an old apps I have to maintain I came across this :
It is a WPF application that was recently converted to .NET 4.0 and this code runs inside a background worker
if(bgWorker1.IsBusy || bgWorker2.IsBusy)
{
Thread.Sleep(100);
Application.Current.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Background,
new System.Threading.ThreadStart(delegate { })
);
}
1 - What possible side-effect would be acheived by invoking a thread (main gui) with a no-op delegate. The other two threads also perform invokes on the main gui thread but only this one sets the priority to something else than Normal (they use Action rather than TreadStart though).
2 - I have cases that strangely resembles deadlock with this application and something tells me that this could be the cause. (mucking around the priority and main gui thread for no appearant reason).
Thanks