public Task SendAsync(Func <Task> work, bool checkLock, int timeOut)
        {
            ActionAsyncWrapper at = new ActionAsyncWrapper(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);
        }
Beispiel #2
0
        public Task SendAsync(Func <Task> work, bool checkLock = true, int timeOut = TIME_OUT)
        {
            if (Settings.Ins.IsDebug)
            {
                return(checkActor.SendAsync(work, checkLock, timeOut));
            }

            ActionAsyncWrapper at = new ActionAsyncWrapper(work);

            at.Owner   = this;
            at.TimeOut = timeOut;
            actionBlock.SendAsync(at);
            return(at.Tcs.Task);
        }