Permalink
Browse files

DateTime is awful. DateTimeOffset is the replacement.

  • Loading branch information...
1 parent 4f36fc3 commit b473d5425fb3723f446841c196a3ac0aa93644ec @smarx committed Aug 10, 2012
Showing with 7 additions and 7 deletions.
  1. +5 −5 AutoRenewLease.cs
  2. +2 −2 Properties/AssemblyInfo.cs
View
@@ -41,23 +41,23 @@ public static void DoEvery(CloudBlob blob, TimeSpan interval, Action action)
{
while (true)
{
- var lastPerformed = DateTime.MinValue;
+ var lastPerformed = DateTimeOffset.MinValue;
using (var arl = new AutoRenewLease(blob))
{
if (arl.HasLease)
{
blob.FetchAttributes();
- DateTime.TryParseExact(blob.Metadata["lastPerformed"], "R", CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out lastPerformed);
- if (DateTime.UtcNow >= lastPerformed + interval)
+ DateTimeOffset.TryParseExact(blob.Metadata["lastPerformed"], "R", CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out lastPerformed);
+ if (DateTimeOffset.UtcNow >= lastPerformed + interval)
{
action();
- lastPerformed = DateTime.UtcNow;
+ lastPerformed = DateTimeOffset.UtcNow;
blob.Metadata["lastPerformed"] = lastPerformed.ToString("R");
blob.SetMetadata(arl.leaseId);
}
}
}
- var timeLeft = (lastPerformed + interval) - DateTime.UtcNow;
+ var timeLeft = (lastPerformed + interval) - DateTimeOffset.UtcNow;
var minimum = TimeSpan.FromSeconds(5); // so we're not polling the leased blob too fast
Thread.Sleep(
timeLeft > minimum
@@ -28,5 +28,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("5.1.0.0")]
-[assembly: AssemblyFileVersion("5.1.0.0")]
+[assembly: AssemblyVersion("5.2.0.0")]
+[assembly: AssemblyFileVersion("5.2.0.0")]

0 comments on commit b473d54

Please sign in to comment.