data = (DefaultWatcherData) watches [fsw];
if (data != null) {
data.Enabled = false;
- data.DisabledTime = DateTime.Now;
+ data.DisabledTime = DateTime.UtcNow;
}
}
}
{
if (!data.Enabled) {
return (data.DisabledTime != DateTime.MaxValue &&
- (DateTime.Now - data.DisabledTime).TotalSeconds > 5);
+ (DateTime.UtcNow - data.DisabledTime).TotalSeconds > 5);
}
DoFiles (data, data.Directory, dispatch);
s.SendBufferSize = bytes.Length;
s.SendTo (bytes, bytes.Length, SocketFlags.None, target);
- DateTime sentTime = DateTime.Now;
+ var sw = Stopwatch.StartNew ();
// receive
bytes = new byte [100];
}
throw new NotSupportedException (String.Format ("Unexpected socket error during ping request: {0}", error));
}
- long rtt = (long) (DateTime.Now - sentTime).TotalMilliseconds;
+ long rtt = (long) sw.ElapsedMilliseconds;
int headerLength = (bytes [0] & 0xF) << 2;
int bodyLength = rc - headerLength;
private PingReply SendUnprivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
{
#if MONO_FEATURE_PROCESS_START
- DateTime sentTime = DateTime.UtcNow;
+ var sw = Stopwatch.StartNew ();
Process ping = new Process ();
string args = BuildPingArgs (address, timeout, options);
string stderr = ping.StandardError.ReadToEnd ();
#pragma warning restore 219
- trip_time = (long) (DateTime.UtcNow - sentTime).TotalMilliseconds;
+ trip_time = (long) sw.ElapsedMilliseconds;
if (!ping.WaitForExit (timeout) || (ping.HasExited && ping.ExitCode == 2))
status = IPStatus.TimedOut;
else if (ping.ExitCode == 0)
public DigestSession ()
{
_nc = 1;
- lastUse = DateTime.Now;
+ lastUse = DateTime.UtcNow;
}
public string Algorithm {
if (request == null)
return null;
- lastUse = DateTime.Now;
+ lastUse = DateTime.UtcNow;
NetworkCredential cred = credentials.GetCredential (request.RequestUri, "digest");
if (cred == null)
return null;
return;
DateTime t = DateTime.MaxValue;
- DateTime now = DateTime.Now;
+ DateTime now = DateTime.UtcNow;
ArrayList list = null;
foreach (int key in cache.Keys) {
DigestSession elem = (DigestSession) cache [key];
using System;\r
+using System.Diagnostics;\r
using System.ComponentModel;\r
using System.Web.UI.WebControls;\r
\r
\r
static void Main(string[] args) {\r
Console.WriteLine ("This test should normally take less than a second");\r
- DateTime start = DateTime.Now;\r
+ var sw = Stopwatch.StartNew ();\r
DoTest ();\r
- TimeSpan ts = DateTime.Now - start;\r
+ TimeSpan ts = sw.Elapsed;\r
Console.Write ("Time spent: ");\r
Console.WriteLine (ts.ToString());\r
}\r
byte [] buffer = new byte [200];
// start async Read operation
- DateTime start = DateTime.Now;
+ var sw = Stopwatch.StartNew ();
IAsyncResult ar = stdout.BeginRead (buffer, 0, buffer.Length,
new AsyncCallback (Read), stdout);
- Assert.IsTrue ((DateTime.Now - start).TotalMilliseconds < 1000, "#01 BeginRead was not async");
+ Assert.IsTrue (sw.ElapsedMilliseconds < 1000, "#01 BeginRead was not async");
p.WaitForExit ();
Assert.AreEqual (0, p.ExitCode, "#02 script failure");
req.Headers.Add (HttpRequestHeader.IfNoneMatch, "898bbr2347056cc2e096afc66e104653");
req.IfModifiedSince = new DateTime (2010, 01, 04);
- DateTime start = DateTime.Now;
+ var sw = global::System.Diagnostics.Stopwatch.StartNew ();
HttpWebResponse response = null;
try {
Assert.AreEqual (0, bytesRead, "#3");
}
- TimeSpan elapsed = DateTime.Now - start;
+ TimeSpan elapsed = sw.Elapsed;
Assert.IsTrue (elapsed.TotalMilliseconds < 2000, "#4");
}
}
var req = (HttpWebRequest) WebRequest.Create (url_to_test);
req.Timeout = TimeOutInMilliSeconds;
- Start = DateTime.Now;
+ Start = DateTime.UtcNow;
using (var resp = (HttpWebResponse) req.GetResponse ())
{
var sr = new StreamReader (resp.GetResponseStream (), Encoding.UTF8);
Body = sr.ReadToEnd ();
}
} catch (Exception e) {
- End = DateTime.Now;
+ End = DateTime.UtcNow;
Exception = e;
}
}