Question: Given the following pseudo C# code:

```
public abstract class Worker
{
    public void DoWork()
    {
         Prepare();
         Work();
         Cleanup();
    }

    protected abstract void Work();
}

```

With this design, it is possible, that a derived class (which overrides the `Work()` method) calls the `Work()` method directly.

I'm looking for design tips on how to prevent any subclass to do this call, or at least generate a compiler warning.

Why I want to do this?
The Worker actually dispatches the `Work()` to another thread. `DoWork()` takes care about the locking.

---

I know, this is weird. The `Work()`-body might just consist of a method call to `DoMyWork()` and the object might call `DoMyWork()` somewhere else. It's impossible to intercept that.

Anyways. I appreciate any thoughts on that issue.

Answer: 
Thanks to Eris and Corey I think I figured it out. What about this way:

```
public abstract class Worker
{
    public void DoWork()
    {
         if (Work != null)
         {
             Prepare();
             Work();
             Cleanup();
         }
    }

    protected Action Work { private get; set; }
}

public class ImplWorker {
    public ImplWorker() {
        Work = //whatever
    }
}

```

Still if he really wanted to he can store it somewhere else and stuff. But it goes as far as I can imagine.
If the Work is done using a resource (e.g. remote server, database connection), or it can be changed to be like that, then you could do it like this:

```
public interface IResource
{
}

public abstract class Worker
{
    private class TheResource : IResource
    {
        // implement
    }

    public void DoWork()
    {
        Prepare();

        var resObj = new TheResource();
        Work(resObj);
        // if needed, cleanup/dispose resObj here

        Cleanup();
    }

    protected abstract void Work(IResource resourceObj);
}

```