Question: I want to ability to take a class (written and maintained by a third party), wrap it with some magic C# sugar, that lets me wrap each member function (or more) with a custom locking mechanism (or logging mechanism or whatever).

For example,

```
 class Foo { // someone else wrote this and I can't touch it.
     void A() {}
     void B() {}
     // plus 10,000 other functions I don't want to know about
 }

 class WrappedFoo : Foo { // this is my class, I can do what ever I want
      // this is pseudo code !!
     OnMemberInvoke(stuff) {
        lock {
            Console.WriteLine("I'm calling " + stuff);
            MemberInvoke(stuff);
            Console.Writeline("I'm done calling " + stuff);
        }
     }
     // I could also deal with OnMemberInvokeStart() and OnMemberInvokeDone()
     // pairwise hooks too.
 }

 WrappedFoo wfoo = new WrappedFoo();
 wfoo.A();
 wfoo.B();

```

output

```
 I'm calling A
 I'm done calling A
 I'm calling B
 I'm done calling B

```

Now I think I can do this with `DynamicObjects` and the `TryInvokeMember`, but then I lose all the type checking and tab completion I love about C#. In this example, I mentioned `lock` for thread safety, but I'm looking for a general way of doing this. This code is intended for real-world hardware testing, that needs extra layers of retries, logging, etc.

Answer: 
Every [Service](http://developer.android.com/reference/android/app/Service.html) has its own Context, just use that. You don't need to pass a Service an Activity's Context.

I don't see why you need a specific Activity's Context to call `getSystemService()` and a Service will receive Intents from a BroadcastReceiver as readily as any Activity. 

Also, if the originating Activity is destroyed while this Service is running, the Context will be invalid or the Activity will be leaked.
Perhaps Interprocess communication might help you there.

[Some randomly googled Android IPC slides here](http://kobablog.wordpress.com/2011/06/04/inter-process-communication-of-android/)