void Run() { try { do { Token.ThrowIfCancellationRequested(); Instance.Run(); var Factory = SingletonFactory.GetInstance <ThreadFactory>(); Factory.Dispatch(d => d.Run(Instance)); }while (Instance.Loop || Running); } catch (TaskCanceledException) { } catch (OperationCanceledException) { } catch (Exception ex) { LoggerFactory.GetLogger().LogFatal(ex); } finally { Instance.End(); var Factory = SingletonFactory.GetInstance <ThreadFactory>(); Factory.Dispatch(d => d.End(Instance)); } }