Exemple #1
0
        public ThreadObject CreateAndGetResults(string content)
        {
            ThreadObject obj;

            if (_threadObjectsPool.TryGetValue(Thread.CurrentThread.ManagedThreadId, out obj))
            {
                return(obj);
            }

            obj = new ThreadObject()
            {
                StringContent = content
            };
            while (_lockVersion + 1 != Interlocked.Increment(ref _lockVersion))
            {
                _threadObjectsPool.Add(Thread.CurrentThread.ManagedThreadId, new ThreadObject {
                    StringContent = content
                });
                Thread.Sleep(1);
            }

            return(obj);
        }
Exemple #2
0
 public Director(IBuilder builder, string content)
 {
     _result = builder.CreateAndGetResults(content);
 }