public void WriteClientActivity(ClientActivity activity) { if (_writer != null && activity != null) { TimeSpan tspan = activity.EndTime - activity.StartTime; WriteSingleLine("activity [duration(ms) :" + tspan.TotalMilliseconds + " start_time :" + activity.StartTime.ToString(TIME_FORMAT) + " end_time :" + activity.EndTime.ToString(TIME_FORMAT) + "]"); if (activity.Activities != null) { for (int i = 0; i < activity.Activities.Count; i++) { MethodActivity mActivity = activity.Activities[i] as MethodActivity; if (mActivity != null) { int space2 = 40; string line = null; line = mActivity.Time.ToString(TIME_FORMAT) + ": " + mActivity.MethodName.PadRight(space2, ' ') + mActivity.Log; lock (_sync_mutex) { _writer.WriteLine(line); _writer.Flush(); } } } } WriteSingleLine("activity ends"); WriteSingleLine(""); } }
public void LogActivity(string method, string log) { ClientActivity activity = _currentActivities[Thread.CurrentThread.ManagedThreadId] as ClientActivity; if (activity != null) { activity.LogActivity(method, log); } }
public object Clone() { ClientActivity clone = new ClientActivity(); lock (this) { clone._startTime = _startTime; clone._endTime = _endTime; clone._activities = _activities.Clone() as ArrayList; } return clone; }
public void StartActivity() { ClientActivity acitvity = new ClientActivity(); acitvity._thread = Thread.CurrentThread; int tId = Thread.CurrentThread.ManagedThreadId; lock (_currentActivities.SyncRoot) { _currentActivities.Add(tId, acitvity); } }
public object Clone() { ClientActivity clone = new ClientActivity(); lock (this) { clone._startTime = _startTime; clone._endTime = _endTime; clone._activities = _activities.Clone() as ArrayList; } return(clone); }
public void StopActivity() { int tId = Thread.CurrentThread.ManagedThreadId; ClientActivity activity = null; lock (_currentActivities.SyncRoot) { activity = _currentActivities[tId] as ClientActivity; _currentActivities.Remove(tId); } if (activity != null) { activity.StopActivity(); lock (_activities.SyncRoot) { _activities.Add(activity); } } }
public void WriteClientActivity(ClientActivity activity) { if (_writer != null && activity != null) { TimeSpan tspan = activity.EndTime - activity.StartTime; WriteSingleLine("activity [duration(ms) :" +tspan.TotalMilliseconds + " start_time :" + activity.StartTime.ToString(TIME_FORMAT) + " end_time :" + activity.EndTime.ToString(TIME_FORMAT) + "]"); if (activity.Activities != null) { for (int i = 0; i < activity.Activities.Count; i++) { MethodActivity mActivity = activity.Activities[i] as MethodActivity; if (mActivity != null) { int space2 = 40; string line = null; line = mActivity.Time.ToString(TIME_FORMAT) + ": " + mActivity.MethodName.PadRight(space2, ' ') + mActivity.Log; lock (_sync_mutex) { _writer.WriteLine(line); _writer.Flush(); } } } } WriteSingleLine("activity ends"); WriteSingleLine(""); } }