public void Shutdown()
        {
            if (logger.IsDebugEnabled)
            {
                logger.Debug(GetType().Name + " thread request shutdown");
            }
            context.RequestShutdown();

            if (beaconSenderThread != null)
            {
#if !(NETCOREAPP1_0 || NETCOREAPP1_1 || WINDOWS_UWP || NETPCL4_5)
                beaconSenderThread.Interrupt();                     // not available in .NET Core 1.0 & .NET Core 1.1
                                                                    // might cause up to 1s delay at shutdown
#endif
#if WINDOWS_UWP || NETPCL4_5
                beaconSenderThread.Wait(SHUTDOWN_TIMEOUT);
#else
                beaconSenderThread.Join(SHUTDOWN_TIMEOUT);
#endif
                if (logger.IsDebugEnabled)
                {
                    logger.Debug(GetType().Name + " thread stopped");
                }
            }
        }
        public void Join(int waitTimeInMillis)
        {
            lock (this)
            {
                if (thread == null)
                {
                    return;
                }
            }

#if !(NETCOREAPP1_0 || NETCOREAPP1_1 || WINDOWS_UWP || NETSTANDARD1_1)
            thread.Interrupt(); // not available in .NET Core 1.0 & .NET Core 1.1
#endif
#if WINDOWS_UWP || NETSTANDARD1_1
            thread.Wait(waitTimeInMillis);
#else
            thread.Join(waitTimeInMillis);
#endif
        }