For a long time I've periodically searched information about creating shared access to serial port in multimodule Prism MVVM application but there are not any good papers. Therefore I address to you here. I develop C# WPF MVVM Prism 6 application using MS VS 2015 Professional in Windows 10 64-bites OS. The solution is consisting of:
- Shell (main window) project.
- Multiple Prism modules projects.
- ClassLibrary project with global access from all these Prism modules and from Shell.
I need shared access to one SerialPort instance from all Prism modules in the application for communication with outer device. What is the best approach to solve this problem about shared serial port? If I create SerialPort as public static member and put it in one of the static class in the above mentioned ClassLibrary, will this way be the best one? Or put such SerialPort instance in shared service will be the best? Or any other solutions about shared SerialPort instance have place? So please advice me how to define globally accessed shared SerialPort in multimodule Prism 6 WPF MVVM application?