コード例 #1
0
        static void SomeBoringTask()
        {
            Pool.WaitOne();

            // do something in the task
            var item = new CustomClass();
            item.AddItems();
            item.CreateTempFile();

            // have a nap
            Thread.Sleep(Random.Next(5000, 10000));

            Console.WriteLine("Task {0} finished", item.Id);
            // release the semaphore
            Pool.Release();
            count--;
            UpdateMessage();
        }