public SubscriberCallbackAttribute(Type eventType, NotifyPriority priority = DEFAULT_PRIORITY, ThreadMode threadMode = DEFAULT_THREAD_MODE) { EventType = eventType; Priority = priority; ThreadMode = threadMode; }
public SubscriberCallbackAttribute(Type eventType, NotifyPriority priority = DEFAULT_PRIORITY, ThreadMode threadMode = DEFAULT_THREAD_MODE) { EventType = eventType; Priority = priority; ThreadMode = threadMode; }
public AnonymousSubscriber( Action <T> action, ThreadMode threadMode, bool stack, IThreadHelper threadHelper) : base(Description.FromGeneric <T>(threadMode, stack), action, threadHelper) { }
//>>>>>>>>>>the slowest /*var target1 = Expression.Property(Expression.Constant(_subscriber), typeof(WeakReference), "Target"); * var target = Expression.Constant(Subscriber); * MethodCallExpression methodCall = Expression.Call(target, method); * _callback = Expression.Lambda<Action>(methodCall).Compile();*/ //>>>>>>>>>>it will keep the object reference //_callback = (Action) method.CreateDelegate(typeof(Action), Subscriber); //>>>>>>>>>30% slower than delegate //_callback = method.Invoke(Subscriber); public Subscription(object subscriber, MethodInfo method, Type eventType, NotifyPriority priority, ThreadMode threadMode) { _subscriber = new WeakReference(subscriber); Priority = priority; EventType = eventType; ThreadMode = threadMode; InitMethod(subscriber, method); }
public static Description FromGeneric <T>(ThreadMode threadMode, bool stack) { return(new Description { ThreadMode = threadMode, ParameterType = typeof(T), Stack = stack }); }
/// <summary> /// Register a <see cref="Action{T}"/> to listen to an incomming message. /// You should keep the instance of the <see cref="Action{T}"/> to unregister /// later if you need. /// </summary> /// <typeparam name="T"> /// Type of incomming message which wants to receive. /// </typeparam> /// <param name="subscriberAction"> /// The <see cref="Action{T}"/> will be called when the incomming message is reached. /// The message data will be passed to the argument of <see cref="subscriberAction"/>. /// </param> /// <param name="threadMode"> /// Configure thead mode, see <see cref="ThreadMode"/> for more detail. /// </param> /// <param name="stack"> /// If it's true, it itents to receive stacked messages. /// </param> public void Register <T>(Action <T> subscriberAction, ThreadMode threadMode, bool stack) { Precondition.ArgumentNotNull(subscriberAction, nameof(subscriberAction)); lock (_subscriberList) { var subscriber = new AnonymousSubscriber <T>(subscriberAction, threadMode, stack, _threadHelper); RegisterSubscriber(subscriber); } }
//Перевод из режима расчета в строку public static string ToRussian(this ThreadMode m) { switch (m) { case ThreadMode.Periodic: return("Периодический"); case ThreadMode.Single: return("Разовый"); case ThreadMode.RealTime: return("Моментальный"); case ThreadMode.Hand: return("Ручной"); case ThreadMode.Error: return(""); } return(""); }
//Перевод из режима расчета в строку public static string ToCode(this ThreadMode m) { switch (m) { case ThreadMode.Periodic: return("Periodic"); case ThreadMode.Single: return("Single"); case ThreadMode.RealTime: return("RealTime"); case ThreadMode.Hand: return("Hand"); case ThreadMode.Error: return(""); } return(""); }
public static void ThrowManagedException(ThreadMode mode) { switch (mode) { case ThreadMode.MainThread: Exceptions.ThrowManagedExceptionThroughNativeCode(); break; case ThreadMode.BackgroundThread: new Thread(Exceptions.ThrowManagedExceptionThroughNativeCode) { IsBackground = true, }.Start(); break; case ThreadMode.ThreadPool: ThreadPool.QueueUserWorkItem((v) => Exceptions.ThrowManagedExceptionThroughNativeCode()); break; default: throw new ArgumentOutOfRangeException(nameof(mode), $"Unknown thread mode: ${mode}"); } }
public EventMethodInfo(UnityEngine.Object subscribe, MethodInfo method, EventCode type, string methodName, ThreadMode mode, bool sticky) { this.Subscribe = subscribe; this.Method = method; this.EventType = type; this.Mode = mode; this.Sticky = sticky; this.MethodName = methodName; }
/// <seealso cref="Register{T}(Action{T}, ThreadMode, bool)"/> public void Register <T>(Action <T> subscriberAction, ThreadMode threadMode) { Precondition.ArgumentNotNull(subscriberAction, nameof(subscriberAction)); Register(subscriberAction, threadMode, false); }
public SubscribeAttribute(ThreadMode mode = ThreadMode.Post) { ThreadMode = mode; }
/// <summary> /// Initializes a new <see cref="ThreadModeAttribute"/> and sets the <see cref="ThreadMode"/>. /// </summary> /// <param name="mode">The type's thread mode.</param> public ThreadModeAttribute(ThreadMode mode) { this.Mode = mode; }
public static extern bool FinalizeNexPlugin(); // 0x00F916C0-0x00F916E0 public static bool InitializeNexAsync(out uint asyncId, ThreadMode threadMode, AsyncResultCB callback = null) { asyncId = default; return default; } // 0x00F916E0-0x00F916F0
} // 0x00F916E0-0x00F916F0 public static extern bool InitializeNex(ThreadMode threadMode); // 0x00F91800-0x00F91820
public Subscribe(ThreadMode threadMode) { this.threadMode = threadMode; }
public SubscriberAttribute(ThreadMode ThreadMode = ThreadMode.Main) { this._threadMode = ThreadMode; }
/// <summary> /// /// </summary> /// <param name="mode"></param> public ThreadModeAttribute(ThreadMode mode) { ThreadMode = mode; }