Table of Contents

Class EmitWorkerRoundRobinProxy

Namespace
Utils.Reflection.Reflection.Emit
Assembly
Utils.Reflection.dll

DispatchProxy that round-robins each call across a fixed set of independent isolated Emit worker processes, produced by EmitRoundRobin<TInterface>(string, CallingConvention, int, TimeSpan?, TimeSpan?).

public class EmitWorkerRoundRobinProxy : DispatchProxy
Inheritance
EmitWorkerRoundRobinProxy
Inherited Members
Extension Methods

Remarks

Complements the in-process concurrency Utils.Reflection.Reflection.Emit.EmitWorkerProcess already supports (several calls in flight on the same worker — see InvokeMethod(int, MethodInfo, object[])): that requires the native library backing the interface to itself be safe to call concurrently, since every call ends up in the same worker process. Round-robining across separate worker processes instead sidesteps that requirement entirely — each process has its own independent load of the native DLL — at the cost of one full sandboxed process per member of the set (see Emit<TInterface>(string, CallingConvention, TimeSpan?, TimeSpan?)'s per-process startup cost) rather than one process total.

Each worker is protected by a SemaphoreSlim(1, 1) so at most one invocation runs on any single worker process at a time. If more concurrent callers arrive than there are workers, the excess callers wait (blocking) until a worker becomes available. This guarantees that each underlying native DLL instance never sees a concurrent call, fulfilling the non-concurrent-access contract that motivated choosing round-robin over the single-worker Emit<TInterface>(string, CallingConvention, TimeSpan?, TimeSpan?).

Methods

Invoke(MethodInfo?, object?[]?)

Whenever any method on the generated proxy type is called, this method is invoked to dispatch control.

protected override object? Invoke(MethodInfo? targetMethod, object?[]? args)

Parameters

targetMethod MethodInfo

The method the caller invoked.

args object[]

The arguments the caller passed to the method.

Returns

object

The object to return to the caller, or null for void methods.