Let's say I have a disposable type:

```
class MyDisposable : IDisposable
{
    public void Dispose() { }
}

```

Then I want every thread to have its own local copy of this class, one per thread:

```
private readonly ThreadLocal<MyDisposable> localMyDisposable
    = new ThreadLocal<MyDisposable>(() => new MyDisposable());

```

Now I want to make sure that *right before the thread exits*, I call `Dispose()` on the value, if it was created. Is there any way to do that? Some threads in my application are short-lived and some are long-lived. I want to make sure any short-lived ones dispose of their values.