Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Core/Reactive/Concurrency/Stopwatch.Default.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 #if !NO_STOPWATCH
4 using System.Diagnostics;
5
6 namespace System.Reactive.Concurrency
7 {
8 //
9 // WARNING: This code is kept *identically* in two places. One copy is kept in System.Reactive.Core for non-PLIB platforms.
10 // Another copy is kept in System.Reactive.PlatformServices to enlighten the default lowest common denominator
11 // behavior of Rx for PLIB when used on a more capable platform.
12 //
13 internal class DefaultStopwatch/*Impl*/ : IStopwatch
14 {
15 private readonly Stopwatch _sw;
16
17 public DefaultStopwatch()
18 {
19 _sw = Stopwatch.StartNew();
20 }
21
22 public TimeSpan Elapsed
23 {
24 get { return _sw.Elapsed; }
25 }
26 }
27 }
28 #else
29 namespace System.Reactive.Concurrency
30 {
31 // This class is only used on Silverlight in the browser. It mimicks !Stopwatch.HighResolution behavior and suffers from
32 // use of absolute time. See work item 486045.
33 internal class DefaultStopwatch : IStopwatch
34 {
35 private readonly DateTime _start;
36
37 public DefaultStopwatch()
38 {
39 _start = DateTime.UtcNow;
40 }
41
42 public TimeSpan Elapsed
43 {
44 get { return DateTime.UtcNow - _start; }
45 }
46 }
47 }
48 #endif