Home / Posts tagged "Delegate"

DynamicInvoke for CF 2.0

March 22nd, 2009 at 22:14 Ryan Rogers

This solution only works for .Net CF prior to 3.5 as the Target and Method properites did not exist before that. Any ideas how to “fake” DynamicInvoke for CF 2.0? I am using extension methods through the ExtensionAttribute trick.
Delegatedynamicinvoke-for-net-compact-framework

Hello Ryan,

The problem is that the .NET compact framework 2.0 is lacking some really important functionality. What we can get by using ugly reflection code is the target object where the delegate points to and the method pointer of the target method.
Continue reading

Dynamically create delegates

Recently I was facing a problem regarding delegates. I needed to dynamically create a delegate which “points to” a dynamically reflected method which is not static on a given type. The problem was, that at the time of the “inspection” of the type I had no instance of that type available. Normally delegates “pointing to” instances are said to be closed on a given  instance therefore you need to have a concrete instance of the type available which the delegate can be bound to.

An example of a closed delegate is the following:

public delegate void MyDelegate(string parameter)

But what happens if you don’t have an instance of a given type present at the time of inspection and you want to dynamically create and later assign the delegate to a type?

Continue reading

Part II: Mimic SynchronizationContext behaviour on .NET CF

Not long ago I posted the first part of this article under:

Part I: Mimic SynchronizationContext behaviour on .NET CF

The article was intended to give the reader a better feeling of the purpose of the SynchronizationContext and the importance of the class on behalf of synchronization between different apartment threads. Unfortunately the SynchronizationContext is not available on the .NET compact framework which is especially annoying when you want to port existing code which uses the SynchronizationContext onto the compact framework platform. So how can we obtain similar functionality on the compact framework?
Continue reading

Part I: Mimic SynchronizationContext behaviour on .NET CF

Before I got into the details of the problem I want to briefly describe what the SynchronizationContext class really does and what it’s main purpose really is in the first part of the article. From that perspective I’m going to show how the basic functionality of the SynchronizationContext class can be implemented for the .NET compact framework in the second part of the article..

Continue reading

Delegate.DynamicInvoke for .NET Compact Framework

As you might already know I’m a certified windows mobile application developer. My speciality is hybrid application development for applications which target both the full .NET framework platform and also the mobile platform. Of course nobody wants to write the same code for each platform again so you have to come up with some tricks and solutions to overcome some limitations on the compact framework.

Continue reading