public static void InvokeMonitor(this PSharpRuntime @this, MonitorId target, Event e)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            @this.InvokeMonitor(target.MonitorType, e);
        }
        public static void RemoteInvokeMonitor(this PSharpRuntime @this, MonitorId target, Event e)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            if (@this.NetworkProvider is ICommunicationProvider networkProvider2)
            {
                networkProvider2.RemoteMonitor(target, e);
                return;
            }

            @this.InvokeMonitor(target, e);
        }
        public static MonitorId NewMonitor(this PSharpRuntime @this, Type type, Event e)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            var monitorId = new MonitorId(@this, type);

            if (!GetRegisteredMonitors(@this).TryAdd(monitorId, null))
            {
                return(monitorId);
            }

            ms_extProps.GetOrCreateValue(@this).LastCreatedMonitorId = monitorId;
            @this.RegisterMonitor(type);
            if (e != null)
            {
                @this.InvokeMonitor(monitorId, e);
            }
            return(monitorId);
        }
 internal static void SetMonitorId(this PSharpRuntime @this, MachineId internalMonitorId, MonitorId monitorId)
 {
     ms_extProps.GetOrCreateValue(@this).MonitorIdMap.AddOrUpdate(internalMonitorId, monitorId, (key, value) => monitorId);
 }