using System;
namespace Digi.Common
{
    public class StopWatch
    {
        private DateTime start;
        private TimeSpan elapsed;
        private bool bRunning = false;

        public void Start()
        {
            start = DateTime.Now;
            bRunning = true;
        }

        public TimeSpan Stop()
        {
            elapsed = DateTime.Now - start;
            bRunning = false;
            return elapsed;
        }

        public TimeSpan Elapsed()
        {
            if (bRunning)
                return DateTime.Now - start;
            else
                return elapsed;
        }

        public bool isRunning()
        {
            return bRunning;
        }
    }
}