Frage

Could you give more explanations on MvvmCross multithreading?

ViewModel calls to Views are safe, so there must be no any conflicts.

However, IMvxMessanger has SubscribeOnThreadPoolThread and also SubscribeOnMainThread (except just Subscribe), which are not really clear for me when to use them.

Also, what's about multithreading inside of ViewModel (for instance, if two web-requests are activated simultaneously and on their results each of them tries to access my dataservice (for instance, writing data to database))?

(Or there are some other such special situations you know from your experiense).

Thank you!

War es hilfreich?

Lösung

For the single technical question about the differences between the subscribe methods on the messenger, these are explained in the XML comments on the interface (but are also largely self-explanatory anyway)

  • subscribe on main thread - messages will be received on main thread
  • subscribe on thread pool thread - messages will be received on a thread pool thread
  • subscribe - messages will be received, no assumptions should be made about which thread

Xml comments at - https://github.com/slodge/MvvmCross/blob/v3/Plugins/Cirrious/Messenger/Cirrious.MvvmCross.Plugins.Messenger/IMvxMessenger.cs#L15


For the rest of the question: as an app developer, you are free to use threading and async in your code - and the normal c# and .net multithreading objects are there for you to use (or a portable subset of them) - synchronising access to a resource is just a normal development decision and technique.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top