This page covers an advanced topic you probably won't need in most situations.
MathContext is part of the
Microkernel Module and provides a thread and stack-relative context. You may use this class for example to simulate -
just for now - some parts of a system in a new, different simulation apartment. This might be useful e.g. if you want to compute some sub-circuit independent of the rest of the system (and maybe with a different scheduler algorithm).
Edit Context Stack Injection
All contexts share the same root, but the rest of the topology forms a separate stack for each thread. To inject a new context into the current thread's stack, use the following pattern (to ensure the context is disposed and thus removed from the stack):
using(MathContext ctx = MathContext.Create())
{
// ...
}
Edit Simulation Apartment Injection
The Simulation Mediator of the
Simulation Module considers the MathContext when selecting a Scheduler. If you want to inject a separate scheduler, simply inject a new context and then create the new apartment:
using(MathContext ctx = MathContext.Create())
{
Service<ISimulationMediator>.Instance.CreateSimulationApartement(yourScheduler);
// ...
}