Esempio n. 1
0
        public static void WaitForAll()
        {
            var Factory = SingletonFactory.GetInstance <ThreadFactory>();

            while (Factory.Tasks.Any(kp => kp.Value.Running))
            {
            }
        }
Esempio n. 2
0
 public static bool RegisterConfiguration(Type ConfigurationType)
 {
     if (typeof(IConfiguration).IsAssignableFrom(ConfigurationType))
     {
         var Factory = SingletonFactory.GetInstance <ConfigurationFactory>();
         return(false);
     }
     throw new Exception($"Class {ConfigurationType} don't implements IConfiguration");
 }
Esempio n. 3
0
        static void Clear(int ID)
        {
            var Factory = SingletonFactory.GetInstance <StackFactory>();

            if (Factory.Stacks.ContainsKey(ID))
            {
                lock (Factory.Stacks[ID])
                    Factory.Stacks[ID].Clear();
            }
        }
Esempio n. 4
0
        static object Pop(int ID)
        {
            var Factory = SingletonFactory.GetInstance <StackFactory>();

            if (Factory.Stacks.ContainsKey(ID))
            {
                lock (Factory.Stacks[ID])
                    return(Factory.Stacks[ID].Pop());
            }
            return(null);
        }
Esempio n. 5
0
        static object Dequeue(int ID)
        {
            var Factory = SingletonFactory.GetInstance <QueueFactory>();

            if (Factory.Queues.ContainsKey(ID) && Factory.Queues[ID].Count > 0)
            {
                lock (Factory.Queues[ID])
                    return(Factory.Queues[ID].Dequeue());
            }
            return(null);
        }
Esempio n. 6
0
        public static void Start(IThread Thread)
        {
            var Factory = SingletonFactory.GetInstance <ThreadFactory>();
            var ID      = Thread.GetHashCode();

            if (!Factory.Tasks.ContainsKey(ID))
            {
                lock (Factory.syncLock)
                    Factory.Tasks.Add(ID, new ThreadTask(Thread));
            }

            Start(ID);
        }
Esempio n. 7
0
        public static ILogger GetLogger([CallerFilePathAttribute] string Name = "")
        {
            Name = Path.GetFileNameWithoutExtension(Name);

            var Factory = SingletonFactory.GetInstance <LoggerFactory>();

            if (!Factory.Loggers.ContainsKey(Name))
            {
                var Logger = (ILogger)Activator.CreateInstance(LoggerType, Name);
                Factory.Loggers.Add(Name, Logger);
            }
            return(Factory.Loggers[Name]);
        }
Esempio n. 8
0
        static void Push(int ID, object Value)
        {
            var Factory = SingletonFactory.GetInstance <StackFactory>();

            if (!Factory.Stacks.ContainsKey(ID))
            {
                lock (Factory.syncLock)
                    Factory.Stacks.Add(ID, new Stack <object>());
            }

            lock (Factory.Stacks[ID])
                Factory.Stacks[ID].Push(Value);
        }
        public static void Start(IUpdater Updater)
        {
            var Factory = SingletonFactory.GetInstance <UpdaterFactory>();
            var ID      = Updater.GetHashCode();

            if (!Factory.Tasks.ContainsKey(ID))
            {
                lock (Factory.syncLock)
                    Factory.Tasks.Add(ID, new UpdaterTask(Updater));
            }

            Start(ID);
        }
Esempio n. 10
0
        static void Enqueue(int ID, object Value)
        {
            var Factory = SingletonFactory.GetInstance <QueueFactory>();

            if (!Factory.Queues.ContainsKey(ID))
            {
                lock (Factory.syncLock)
                    Factory.Queues.Add(ID, new Queue <object>());
            }

            lock (Factory.Queues[ID])
                Factory.Queues[ID].Enqueue(Value);
        }
Esempio n. 11
0
        static void Start(int ID)
        {
            var Factory = SingletonFactory.GetInstance <ThreadFactory>();
            var Task    = Factory.Tasks[ID];

            if (!Task.Running)
            {
                Task.Start();
            }
            else
            {
                throw new Exception("Thread as already started!");
            }
        }
Esempio n. 12
0
        public static void Start(Type ThreadType)
        {
            if (typeof(IThread).IsAssignableFrom(ThreadType))
            {
                var Factory = SingletonFactory.GetInstance <ThreadFactory>();
                var ID      = ThreadType.GetHashCode();

                Start(ID);
            }
            else
            {
                throw new Exception($"Class {ThreadType} don't implements IThread");
            }
        }
Esempio n. 13
0
        public static void Start(Type UpdaterType)
        {
            if (typeof(IUpdater).IsAssignableFrom(UpdaterType))
            {
                var Factory = SingletonFactory.GetInstance <UpdaterFactory>();
                var ID      = UpdaterType.GetHashCode();



                Start(ID);
            }
            else
            {
                throw new Exception($"Class {UpdaterType} don't implements IUpdater");
            }
        }
Esempio n. 14
0
        static void Stop(int ID)
        {
            var Factory = SingletonFactory.GetInstance <ThreadFactory>();

            if (Factory.Tasks.ContainsKey(ID))
            {
                var Task = Factory.Tasks[ID];

                if (Task.Running)
                {
                    Task.Stop();
                }
                else
                {
                    throw new Exception("Thread as not been started!");
                }
            }
            else
            {
                throw new Exception("Thread as not been created!");
            }
        }
Esempio n. 15
0
        static bool IsRunning(int ID)
        {
            var Factory = SingletonFactory.GetInstance <ThreadFactory>();

            return(Factory.Tasks.ContainsKey(ID) && Factory.Tasks[ID].Running);
        }