Question: assume you have a function that polls some kind of queue and blocks for a certain amount of time. If this time has passed without something showing up on the queue, some indication of the timeout should be delivered to the caller, otherwise the something that showed up should be returned.

Now you could write something like:

```
class Queue
{
    Thing GetThing();
}

```

and throw an exception in case of a timeout. Or you
write

```
class Queue
{
    int GetThing(Thing& t);
}

```

and return an error code for success and timeout.

However, drawback of solution 1 is that the on a not so busy queue timeout is not an exceptional case, but rather common. And solution 2 uses return values for errors and ugly syntax, since you can end up with a `Thing` that contains nothing.

Is there another (smart) solution for that problem? What is the preferred solution in an object oriented environment?

Answer: 
What I would do is write a custom tool to search your source code.

If you remove a resource ID from a header file (i.e. possibly called resource.h) and then recompile and get no warnings: then that's a good thing.

Here is how I would go about writing the app. Take as input the resource file (resource.h) you want to scrutinize. Open the header file (\*.h) and parse all the resource constants (Or at least the onces you are interested in). Store those in a hash table for quick look up later.
For each code file in your project, search the text for instances of each of your resource ID's. When a resource ID is used, increment the value in the hash table otherwise leave it at zero.
At the end, dump all the resource ID's that are zero out a log file or something. Then test that indeed you can remove those specified resource ID's safely. Once you do that, then write another tool that removes the specified resource ID's given the results of your log file.

You could write such a tool in perl and it would execute in about 0.3 seconds: But would take days to debug. :)
Or you could write this in .NET, and it would execute a little slower, but would take you an hour to debug. :)
In the **Solution Explorer**, right click and on a **Reference** and click on the menu item **Find Dependent Code**. 

If it can't find any dependent code then you can remove this reference from the project. (The **Remove** operation is also under the right-click menu.)

**EDIT:** For a large project, the Find Dependent Code operation will take a *long* time. So since you have 2000 resources and most likely *value* your time this probably is **not** a viable option....