anchor.diff:  ﻿namespace MBrace.Azure.Runtime
   
   open System
  -open System.Runtime.Serialization
   open Microsoft.ServiceBus.Messaging
   open MBrace.Azure.Runtime
   open MBrace.Azure.Runtime.Utilities
   open MBrace.Azure
   open MBrace.Core.Internals
  -open System.Threading.Tasks
   open System.IO
  -open MBrace.Runtime.Utils
   open MBrace.Azure.Runtime.Primitives
   open MBrace.Runtime
  -open Nessos.FsPickler.ExtensionMethods
  +open System.Runtime.Serialization
   
   [<AutoOpenAttribute>]
   module private Helpers = 
  
positive.code:                              }
                           renewLoop())
      
      static member Complete(token : JobLeaseToken) : Async<unit> = 
          async { 
              let config = token.ConfigurationId
              match token.TargetWorker with
  
negative.code:                 return! subscription.CompleteAsync(token.MessageLockId)
          }
  
  [<AutoSerializable(true); DataContract>]
  type JobLeaseToken private (info : JobLeaseTokenInfo)  = 
      let [<DataMember(Name="info")>] info = info
  
      member ths.Id               = info.JobId
      member this.ConfigurationId = info.ConfigurationId
      member this.TargetWorker    = info.TargetWorker
      member this.MessageLockId   = info.MessageLockId
      member this.DeliveryCount   = info.DeliveryCount
      member this.ParentJobId     = info.ParentJobId
      member this.DequeueTime     = info.DequeueTime
  
      interface ICloudJobLeaseToken with
          member this.DeclareCompleted() : Async<unit> = 
              async {
                  do! JobLeaseMonitor.Complete(info)
                  let record = new JobRecord(info.ParentJobId, info.JobId)
                  record.Status <- nullable(int JobStatus.Completed)
                  record.CompletionTime <- nullable(DateTimeOffset.Now)
                  let! _record = Table.merge info.ConfigurationId info.ConfigurationId.RuntimeTable record
                  return ()
              }
          
          member this.DeclareFaulted(arg1 : ExceptionDispatchInfo) : Async<unit> = 
              async { 
                  do! JobLeaseMonitor.Complete(info)
                  let record = new JobRecord(info.ParentJobId, info.JobId)
                  record.Status <- nullable(int JobStatus.Faulted)
                  record.CompletionTime <- nullable(DateTimeOffset.Now)
                  let! _record = Table.merge info.ConfigurationId info.ConfigurationId.RuntimeTable record
                  return () 
              }
          
          member this.FaultInfo : JobFaultInfo = failwith "Not implemented yet"
          
          member this.GetJob() : Async<CloudJob> = 
              async { 
                  let blob = Blob.FromPath(info.ConfigurationId, info.ParentJobId, info.JobId)
                  use! stream = blob.OpenRead()
                  let _pos = 
                      match info.Offset with
                      | Some pos -> stream.Seek(pos, SeekOrigin.Begin)
                      | _ -> 0L
                  return Configuration.Pickler.Deserialize<CloudJob>(stream)
              }
          
          member this.Id : string = info.JobId
          
          member this.JobType : JobType = failwith "Not implemented yet"
          
          member this.Size : int64 = failwith "Not implemented yet"
          
          member this.TargetWorker : IWorkerId option = 
              match info.TargetWorker with
              | None -> None
              | Some w -> Some(WorkerId(w) :> _)
          
          member this.TaskEntry : ICloudTaskCompletionSource = TaskCompletionSource(info.ConfigurationId, info.ParentJobId) :> _
          
          member this.Type : string = failwith "Not implemented yet"
      
  