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