Can anyone explain what I need to do to get past this error?
“Cannot convert anonymous method to type ‘System.Windows.Threading.DispatcherPriority’ because it is not a delegate type”
private void Test(object sender)
{
base.Dispatcher.BeginInvoke(delegate
{
//some code
}, new object[0]);
}
Thanks
If you’re using .NET 3.5 SP1 and upwards, then you can add a reference to System.Windows.Presentation.dll and make sure you have
using System.Windows.Threading;at the top of the file. It contains extension methods that are easier to use, and allow you to simply write:If you’re using .NET 3.5 without SP1 or lower, then you’ll have to cast the delegate to a concrete delegate type: