Я попытался скомпилировать следующий код:Вызов неоднозначен между ThreadStart и ParameterizedThreadStart
public class SplashScreenManager
{
private static readonly object mutex = new object();
public static ISplashScreen CreateSplashScreen(Stream imageStream, Size imageSize)
{
object obj;
Monitor.Enter(obj = SplashScreenManager.mutex);
ISplashScreen vm2;
try
{
SplashScreenWindowViewModel vm = new SplashScreenWindowViewModel();
AutoResetEvent ev = new AutoResetEvent(false);
Thread thread = new Thread(delegate
{
vm.Dispatcher = Dispatcher.CurrentDispatcher;
ev.Set();
Dispatcher.CurrentDispatcher.BeginInvoke(delegate //<- Error 2 here
{
SplashForm splashForm = new SplashForm(imageStream, imageSize)
{
DataContext = vm
};
splashForm.Show();
}, new object[0]);
Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true;
thread.Start();
ev.WaitOne();
vm2 = vm;
}
finally
{
Monitor.Exit(obj);
}
return vm2;
}
}
И получил ошибку:
The call is ambiguous between the following methods or properties: 'System.Threading.Thread.Thread(System.Threading.ThreadStart)' and 'System.Threading.Thread.Thread(System.Threading.ParameterizedThreadStart)'
edit1: Я исправленный код и получить ошибку 2 :
Невозможно преобразовать анонимный метод для ввода 'System.Windows.Threading. DispatcherPriority ', потому что он не является делегатом типа
Смотрите ответ я предоставил для фиксации кода для .NET 3.5, а также 4 – chrisw