Click here to Skip to main content
15,888,351 members
Home / Discussions / WPF
   

WPF

 
QuestionPlease help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 10:00
Pew_new4-Sep-18 10:00 
This is in a Class called ST:

C#
 public Class ST
{
   private readonly System.Timers.Timer _timer;
   private DateTime _lastScanTime;
  
 public ST()
        {
            
            _timer = new System.Timers.Timer();
            _timer.Interval = 250;
            _timer.Start();
            _timer.Elapsed += OnTimerElapsed;
        }



         public TimeSpan ScanTime { get; private set; }

          private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                _timer.Stop();
                ScanTime = DateTime.Now - _lastScanTime;
                
                OnValuesRefreshed();
            }
            finally
            {
                _timer.Start();
            }
            _lastScanTime = DateTime.Now;
        }
        
        private void OnValuesRefreshed()
        {
            ValuesRefreshed?.Invoke(this, new EventArgs());
        }
}


Then a value of Scantime is being transferred via MVVM pattern (ViewModel) to UI.
The major question is what do we really have valuable when we do a substraction as follows: ScanTime = DateTime.Now - _lastScanTime? This point I can't figure out.

Thanks in advance!
AnswerRe: Please help me to figure out a purpose of this code. Pin
Mycroft Holmes4-Sep-18 11:29
professionalMycroft Holmes4-Sep-18 11:29 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 18:31
Pew_new4-Sep-18 18:31 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Mycroft Holmes4-Sep-18 19:18
professionalMycroft Holmes4-Sep-18 19:18 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 22:25
Pew_new4-Sep-18 22:25 
AnswerRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan4-Sep-18 21:52
mveRichard MacCutchan4-Sep-18 21:52 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 22:30
Pew_new4-Sep-18 22:30 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan4-Sep-18 22:38
mveRichard MacCutchan4-Sep-18 22:38 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 22:45
Pew_new4-Sep-18 22:45 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan4-Sep-18 23:07
mveRichard MacCutchan4-Sep-18 23:07 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Pew_new4-Sep-18 23:12
Pew_new4-Sep-18 23:12 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan4-Sep-18 23:35
mveRichard MacCutchan4-Sep-18 23:35 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Mycroft Holmes5-Sep-18 11:21
professionalMycroft Holmes5-Sep-18 11:21 
GeneralRe: Please help me to figure out a purpose of this code. Pin
Richard MacCutchan5-Sep-18 21:45
mveRichard MacCutchan5-Sep-18 21:45 
AnswerRe: Please help me to figure out a purpose of this code. Pin
Pete O'Hanlon5-Sep-18 0:44
mvePete O'Hanlon5-Sep-18 0:44 
QuestionWPF Grouping and Grouping Adorners Pin
ameenshabeer3-Sep-18 6:29
ameenshabeer3-Sep-18 6:29 
AnswerRe: WPF Grouping and Grouping Adorners Pin
Pete O'Hanlon3-Sep-18 12:40
mvePete O'Hanlon3-Sep-18 12:40 
QuestionSimpliest code: Can't change label "Content" programmatically Pin
Pew_new2-Sep-18 8:28
Pew_new2-Sep-18 8:28 
AnswerRe: Simpliest code doesn't work Pin
Bernhard Hiller2-Sep-18 22:03
Bernhard Hiller2-Sep-18 22:03 
GeneralRe: Simpliest code doesn't work Pin
Pew_new2-Sep-18 23:10
Pew_new2-Sep-18 23:10 
GeneralRe: Simpliest code doesn't work Pin
Richard Deeming3-Sep-18 10:32
mveRichard Deeming3-Sep-18 10:32 
QuestionWPF: Customizing the appearence of a window n XAML Pin
Pew_new28-Aug-18 21:30
Pew_new28-Aug-18 21:30 
AnswerRe: WPF: Customizing the appearence of a window n XAML Pin
OriginalGriff28-Aug-18 21:32
mveOriginalGriff28-Aug-18 21:32 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
Pew_new29-Aug-18 0:55
Pew_new29-Aug-18 0:55 
GeneralRe: WPF: Customizing the appearence of a window n XAML Pin
OriginalGriff29-Aug-18 1:04
mveOriginalGriff29-Aug-18 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.