1
votes

I have created a prism project consisting of two modules (dll's). The two modules are loaded within a shell and build up following the MVVM pattern.

Module1 receives data which should be transferred (as fast as possible) to Module2. This data could be stored in an observablecollection for example. Which means that if this observablecollection is updated it should update the view in module2. It is a lot of data, so I would not use the eventaggregator for that.

I read something about dependency injection but I'm not sure how to do it. I found several examples where a submit button was pushed to transfer data between two modules. I guess what I need would be somehow a reference of the observablecollection(module1) within the module2. Shared services is another keyword I found.

What would be a good solution to solve this?

An example with an mvvm pattern would be great. I'm new to prism so please be kind.

1
Any reason you cant use events?Nikita B
I want to transfer a huge amount of data coming from a serialport, so I would send data multiple times per second (almost directly from buffer). Is it a good idea to use events for this approach?user2799180

1 Answers

1
votes

There is nothing wrong with using events for such task. It is a common practice to have some interface:

interface IDataReciever<TData>
{
    event Action<TData> DataRecieved;
    //some other methods, such as, for example:
    //void Open();
    //void Close();
}

hinding all the interactions with serial port. You can then pass this interface to your viewmodel constructor, subscribe to event and add data to observable collection (converting it to some model if needed) in the event handler.