SynchronizationContext.Current имеет значение null при разрешении с помощью Unity в WPF

У меня есть код WPF, который выглядит примерно так.

public class AlphaProductesVM : BaseModel
{
    private  ObservableCollection<Alphabetical_list_of_product> _NwCustomers;
    private int i = 0;

    public AlphaProductesVM ()
    {
        _NwCustomers = new ObservableCollection<Alphabetical_list_of_product>();
        var repository = new NorthwindRepository();
           repository
               .GetAllProducts()
               .ObserveOn(SynchronizationContext.Current)
               .Subscribe(AddElement);
    }
    public void AddElements(IEnumerable<Alphabetical_list_of_product> elements)
    {
        foreach (var alphabeticalListOfProduct in elements)
        {
            AddElement(alphabeticalListOfProduct);
        }
    }


    public ObservableCollection<Alphabetical_list_of_product> NwCustomers
    {
        get { return _NwCustomers; }
        set { _NwCustomers = value; }
    }}

Я использую Unity для решения вышеупомянутого AlphaProductesVM . Это происходит мгновенно, когда модуль обнаруживается с помощью PRISM и UnityBootstrapper. Во время выполнения .ObserveOn (SynchronizationContext.Current) вызывает исключение, а SynchronizationContext.Current имеет в нем значение null .

5
задан Enrico Campidoglio 21 February 2012 в 12:41
поделиться