Ejemplo n.º 1
0
        /// <summary>
        /// Add a new delegate call to be executed.
        /// </summary>
        public void Queue(Delegate d, params object[] args)
        {
            if (d == null)
            {
                return;
            }

            lock (_queue)
            {
                string callerName = string.Empty;
                if (Debugger.IsAttached)
                {
                    MethodBase method = ReflectionHelper.GetExternalCallingMethod(2, OwnerTypes);
                    if (method != null)
                    {
                        callerName = method.Name;
                    }
                    else
                    {
                        callerName = "NA";
                    }
                }

                TargetInfo info = new TargetInfo(callerName, d, args);
                _queue.Add(info);
            }

            ProcessQueue();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is dreadfully slow and can overload CPU with only 3000 calls per second!
        /// </summary>
        /// <returns></returns>
        string ObtainCallerName()
        {
            if (Debugger.IsAttached)
            {
                MethodBase method = ReflectionHelper.GetExternalCallingMethod(2, OwnerTypes);
                if (method != null)
                {
                    return(method.Name);
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Perform actual item tracing.
        /// </summary>
        /// <param name="tracer"></param>
        /// <param name="itemType"></param>
        /// <param name="message"></param>
        static public void DoTrace(Tracer tracer, TracerItem.TypeEnum itemType, TracerItem.PriorityEnum priority, string message)
        {
            if (tracer != null && tracer.Enabled)
            {
                string threadId   = Thread.CurrentThread.ManagedThreadId.ToString();
                string threadName = Thread.CurrentThread.Name;

                MethodBase method = ReflectionHelper.GetExternalCallingMethod(3, OwnerTypes);

                MethodTracerItem item = new MethodTracerItem(itemType, priority, message, method);
                tracer.Add(item);
            }
        }