public ParallelLoopResult Microsoft() => Parallel.For(0, Count, _ =>
 {
     MyResource res = null;
     string str;
     try
     {
         res = _microsoftObjectPool.Get();
         str = res.Value;
     }
     finally
     {
         if (res != null)
         {
             _microsoftObjectPool.Return(res);
         }
     }
 });
示例#2
0
        public string Microsoft()
        {
            MyResource res = null;
            string     str;

            try
            {
                res = _microsoftObjectPool.Get();
                str = res.Value;
            }
            finally
            {
                if (res != null)
                {
                    _microsoftObjectPool.Return(res);
                }
            }
            return(str);
        }