示例#1
0
        public override string ToString()
        {
            var result = new StringBuilder();

            result.AppendFormat("Total time: {0:00} ms", Watcher.Elapsed.TotalMilliseconds);
            result.AppendLine();

            TraceItem[] traceItems;
            lock (TraceItemsList)
            {
                traceItems = TraceItemsList.ToArray();
            }

            var counter = 1;

            foreach (var traceItem in traceItems)
            {
                var message = traceItem.Message;

                result.AppendFormat(
                    "{0}. Started at {1}, duration {2}:", counter, traceItem.StartTime, traceItem.Elapsed);
                result.AppendLine();
                result.Append(message);
                result.AppendLine();

                counter++;
            }

            return(result.ToString());
        }
示例#2
0
        public TraceItem StartTraceItem()
        {
            var traceItem = new TraceItem(Watcher);

            lock (TraceItemsList) {
                TraceItemsList.Add(traceItem);
            }
            return(traceItem);
        }