Пример #1
0
        public void Start(Action <T> action, T data)
        {
            if (thread != null)
            {
                return;
            }

            holder = new DataHolder <T>(action, data, true);

            thread = new Thread(new ThreadStart(holder.Loop));
            thread.Start();
        }
Пример #2
0
        public void Stop()
        {
            if (thread == null)
            {
                return;
            }

            holder.SetRunning(false);
            lock (holder.Sync)
                Monitor.Pulse(holder.Sync);

            thread.Join();

            thread = null;
            holder = null;
        }