예제 #1
0
 /// <summary>
 /// Complete a work item (call when receiving reply from system)
 /// </summary>
 public void CompleteWork(string correlationId, SandwichResponse response)
 {
     if (WipList.TryGetValue(correlationId, out WipItem wipItem))
     {
         wipItem.Response = response;
         wipItem.Lock.Set();
     }
     else
     {
         throw new KeyNotFoundException(correlationId);
     }
 }
예제 #2
0
        /// <summary>
        /// Finalize a work item (call to get/process reply,
        /// and to remove work item)
        /// </summary>
        public SandwichResponse FinalizeWork(string correlationId)
        {
            SandwichResponse result = null;

            if (WipList.TryGetValue(correlationId, out WipItem wipItem))
            {
                result = wipItem.Response;
                if (!WipList.TryRemove(correlationId, out WipItem temp))
                {
                    System.Diagnostics.Debug.Fail($"Could not remove WIP item {correlationId}");
                    System.Diagnostics.Debug.Assert(temp != null);
                }
            }
            return(result);
        }