예제 #1
0
 private void UseResource(SystemResource systemResource, int duration)
 {
     Console.WriteLine($"Using resource {systemResource.Name}");
     Thread.Sleep(duration);
     FreeResource(systemResource);
     _queue.Dequeue();
 }
예제 #2
0
 private void FreeResource(SystemResource systemResource)
 {
     Console.WriteLine($"Freeing resource {systemResource.Name}");
     systemResource.Free();
 }
예제 #3
0
 public void AddResource(SystemResource systemResource, int duration)
 {
     _queue.Enqueue(new ResourceRequest(systemResource, duration));
 }