Example #1
0
        public void OnEvent(SampleEvent data, long sequence, bool endOfBatch)
        {
            var task = _persister.SaveAsync(data);

            // It might be useful to store the save result so it
            // can be accessed in next event handlers.
            data.SaveResult = task.WaitTaskResult(_saveTimeout);
        }
Example #2
0
        public void OnEvent(SampleEvent data, long sequence, bool endOfBatch)
        {
            var saveResult = _previousSaveTask.WaitTaskResult(_saveTimeout);

            // TODO: handle the task error.

            _previousSaveTask = _persister.SaveAsync(data);
        }
Example #3
0
        public void OnEvent(SampleEvent data, long sequence, bool endOfBatch)
        {
            var task = _persister.SaveAsync(data);

            // Fire-and-forgetting the task should really be avoid.
            // If you do so, you should add least limit the number of
            // ongoing save tasks, for example using a semaphore.

            task.ContinueWith(t => OnError(t.Exception), TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnFaulted);
Example #4
0
 public void OnEvent(SampleEvent data, long sequence, bool endOfBatch)
 {
     var task = _persister.SaveAsync(data);
     // How to deal with the task in a void method?
 }
Example #5
0
 public void OnBatch(EventBatch <SampleEvent> batch, long sequence)
 {
     var task = _persister.SaveAsync(batch.ToArray());
     // Do something with the task depending on you design option
 }
Example #6
0
 public void OnEvent(SampleEvent data, long sequence, bool endOfBatch)
 {
     data.SaveTask = _persister.SaveAsync(data);
 }