/// <summary> /// Adds new uninitialized event processors instances to this hub. /// </summary> /// /// <param name="amount">The amount of event processors to add.</param> /// public void AddEventProcessors(int amount) { for (int i = 0; i < amount; i++) { var eventProcessor = new ShortWaitTimeMock ( InnerPartitionManager, ConsumerGroup, FullyQualifiedNamespace, EventHubName, ConnectionFactory, ClientOptions ); if (OnInitialize != null) { eventProcessor.PartitionInitializingAsync += eventArgs => { OnInitialize(eventArgs); return(Task.CompletedTask); }; } if (OnStop != null) { eventProcessor.PartitionClosingAsync += eventArgs => { OnStop(eventArgs); return(Task.CompletedTask); }; } eventProcessor.ProcessEventAsync += eventArgs => { OnProcessEvent?.Invoke(eventArgs); return(Task.CompletedTask); }; eventProcessor.ProcessErrorAsync += eventArgs => { OnProcessError?.Invoke(eventArgs); return(Task.CompletedTask); }; EventProcessors.Add(eventProcessor); } }
/// <summary> /// Adds new uninitialized event processors instances to this hub. /// </summary> /// /// <param name="amount">The amount of event processors to add.</param> /// public void AddEventProcessors(int amount) { for (int i = 0; i < amount; i++) { var eventProcessor = new ShortWaitTimeMock ( ConsumerGroup, InnerPartitionManager, Connection, Options ); if (OnInitialize != null) { eventProcessor.InitializeProcessingForPartitionAsyncHandler = initializationContext => { OnInitialize(initializationContext); return(new ValueTask()); }; } if (OnStop != null) { eventProcessor.ProcessingForPartitionStoppedAsyncHandler = stopContext => { OnStop(stopContext); return(new ValueTask()); }; } eventProcessor.ProcessEventAsyncHandler = processorEvent => { OnProcessEvent?.Invoke(processorEvent); return(new ValueTask()); }; eventProcessor.ProcessErrorAsyncHandler = errorContext => { OnProcessException?.Invoke(errorContext); return(new ValueTask()); }; EventProcessors.Add(eventProcessor); } }
private void OnRead(IAsyncResult ar) { if (!CompleteRead(ar)) { return; } try { OnProcessEvent?.Invoke(this, InMessage); OnPostProcessEvent?.Invoke(this); } catch (Exception e) { // Invalid data from the client // TODO: I must not swallow exceptions. Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); // TODO: is closing the connection really necesary? // Close(); } }
private void OnProcessHandle(int layerIndex, IntPtr data, int width, int height, int outputIndex) { OnProcessEvent?.Invoke(layerIndex, data, width, height, outputIndex); }