Beispiel #1
0
        public static IEnumerable <Patient> DoQuery(CancellationToken token)
        {
            Random random = new Random();

            foreach (var item in PatientFactory.GeneratePatient(random.Next(20, 100)))
            {
                if (token.IsCancellationRequested)
                {
                    yield break;
                }
                yield return(item);
            }
        }
Beispiel #2
0
 private void DoQuery(IObserver <WorklistQueryEvent> observer)
 {
     lock (_mutex)
     {
         if (_queryTask.Task.IsCompleted == false)
         {
             return;
         }
         _queryTask   = new TaskCompletionSource <bool>();
         _tokenSource = new CancellationTokenSource();
     }
     observer.OnNext(WorklistQueryEvent.StartEvent());
     foreach (var item in PatientFactory.DoQuery(_tokenSource.Token))
     {
         var @event = WorklistQueryEvent.NewPatient(item);
         observer.OnNext(@event);
     }
     observer.OnNext(WorklistQueryEvent.EndEvent());
     lock (_mutex)
     {
         _queryTask.SetResult(true);
     }
 }