public Task SendAsync(Action work, bool checkLock, int timeOut) { ActionWrapper at = new ActionWrapper(work); at.TimeOut = timeOut; lock (nodeLock) { int thId = TaskScheduler.Current.Id; var newNode = new ActorNode(); if (threadMap.ContainsKey(thId)) { newNode.Parent = threadMap[thId].activeNode; } newNode.Actor = cacheActor; if (work.Target == null || work.Method.DeclaringType.Name.Contains("<>c")) { newNode.Trace = work.Method.DeclaringType.FullName + ":" + work.Method.Name + "(" + work.ToString() + ")"; } else { newNode.Trace = work.Target.GetType().FullName + ":" + work.Method.Name + "(" + work.ToString() + ")"; } if (checkLock) { checkNodeIlegal(newNode); } else { newNode.Parent = null; } at.Node = newNode; } actionBlock.SendAsync(at); return(at.Tcs.Task); }
public Task SendAsync(Action work, bool checkLock = true, int timeOut = TIME_OUT) { if (Settings.Ins.IsDebug) { return(checkActor.SendAsync(work, checkLock, timeOut)); } ActionWrapper at = new ActionWrapper(work); at.Owner = this; at.TimeOut = timeOut; actionBlock.SendAsync(at); return(at.Tcs.Task); }