voltcode
voltcode

Reputation: 33

What is the best way to synchronize access to an object outside ActorSystem in Akka.NET?

I have an ASP.NET application that accesses a class that wraps a Dictionary and may be accessed during page request handling. Akka.NET actor also obtains a reference to that class instance during initialization and may access the class any time.

What's the best way to synchronize access to that Dictionary without breaking Akka.NET's flow? Can using .NET Monitor's break Akka.NET threadpool somehow? I can't change entire application logic to actors and wrap the cache in an actor (yet) so I'd like to hear about (least bad) alternatives.

Upvotes: 2

Views: 288

Answers (2)

Danthar
Danthar

Reputation: 1075

As long as your in this hybrid scenario. I'd recommend to keep it simple and use a ConcurrentDictionary type to synchronise access.

Upvotes: 2

profesor79
profesor79

Reputation: 9473

If you have the opportunity to refactor and have dictionary data served by designated actor, that will be the best approach IMHO.

Upvotes: 0

Related Questions