/// <summary>
        /// Creates thread that will try to trigger event processing with time interval from specified
        /// <see cref="EventDataHandler{T, V}"/>
        /// </summary>
        /// <param name="dataHandler">
        /// the
        /// <see cref="EventDataHandler{T, V}"/>
        /// for which the thread will be registered
        /// </param>
        ///
        ///
        public static void RegisterTimedProcessing <T, V>(EventDataHandler <T, V> dataHandler)
            where V : EventData <T>
        {
            Thread thread = new Thread(() => {
                while (true)
                {
                    try {
                        Thread.Sleep((int)dataHandler.GetWaitTime().GetTime());
                        dataHandler.TryProcessNextAsync(false);
                    }
#if !NETSTANDARD1_6
                    catch (ThreadInterruptedException any) {
                        break;
                    }
#endif
                    catch (Exception any) {
                        LogManager.GetLogger(typeof(iText.Kernel.Counter.Data.EventDataHandlerUtil)).Error(iText.IO.LogMessageConstant
                                                                                                           .UNEXPECTED_EVENT_HANDLER_SERVICE_THREAD_EXCEPTION, any);
                        break;
                    }
                }
            });

            thread.IsBackground = true;
            thread.Start();
        }
        /// <summary>
        /// Registers shutdown hook for
        /// <see cref="EventDataHandler{T, V}"/>
        /// that will try to process all the events that are left.
        /// It isn't guarantied that all events would be processed.
        /// </summary>
        /// <param name="dataHandler">
        /// the
        /// <see cref="EventDataHandler{T, V}"/>
        /// for which the hook will be registered
        /// </param>
        ///
        ///
        public static void RegisterProcessAllShutdownHook <T, V>(EventDataHandler <T, V> dataHandler)
            where V : EventData <T>
        {
            try {
#if !NETSTANDARD1_6
                AppDomain.CurrentDomain.ProcessExit  += (s, e) => dataHandler.TryProcessRest();
                AppDomain.CurrentDomain.DomainUnload += (s, e) => dataHandler.TryProcessRest();
#else
                AssemblyLoadContextUtil.RegisterUnloadingEvent(context => dataHandler.TryProcessRest());
                AssemblyLoadContextUtil.RegisterUnloadingEvent(context => dataHandler.TryProcessRest());
#endif
            }
            catch (SecurityException) {
                LogManager.GetLogger(typeof(iText.Kernel.Counter.Data.EventDataHandlerUtil)).Error(iText.IO.LogMessageConstant
                                                                                                   .UNABLE_TO_REGISTER_EVENT_DATA_HANDLER_SHUTDOWN_HOOK);
            }
            catch (Exception) {
            }
        }