What I meant by
"I can use a conditional compile and use a simple delegate in CF"
is that the classes that use WeakMulticastDelegate in our framework
could use a simple delegate in CF with a conditional compile and I
would exclude this class from the CF solution.
Sébastien
On 8/3/06, Sébastien Lorion <[EMAIL PROTECTED]> wrote:
So how does .NET 2.0 CF deals with delegate targets ? Do they prevent
objects from being garbage collected ?
Of course I can use a conditional compile and use a simple delegate in
CF, but if delegate still keep a strong reference to their target,
then I would need to find a way around that.
Sébastien
On 8/3/06, Frans Bouma <[EMAIL PROTECTED]> wrote:
> You could use a conditional compile, which makes the routine not usable on
CF.NET but that's a given, as CF.NET can't deal with the
> feature you need anyway.
>
> A conditional compile then could make your code compilable on .NET 2.0 and
CF.NET 2.0 as well.
>
> Be sure that if you use the Serializable attribute and you write a dummy
class to make the code compile on CF.NET 2.0, the CF.NET
> 2.0 SP1 contains also that attribute (for whatever reason, remoting isn't
supported on cf.net) so it will give type clashes.
>
> FB
>
> > Hello everyone,
> >
> > I am in the process of adapting our internal framework (for
> > .NET 2.0) to the .NET 2.0 CF (target is Windows CE 5.0).
> >
> > So far, it is only a matter of removing stuff and using
> > different overloads, but now I got this problem:
> >
> > We have a WeakMulticastDelegate class that we use in various places.
> > This class is just like a delegate, but the target is a
> > WeakReference instead. The problem I have is that there is no
> > Target and Method properties on delegates in .NET 2.0 CF. How
> > can I replace them in this code for example:
> >
> > public WeakMulticastDelegate(Delegate strongDelegate) {
> > if (strongDelegate == null)
> > throw new ArgumentNullException("strongDelegate");
> >
> > Delegate[] delegates = strongDelegate.GetInvocationList();
> >
> > if (delegates.Length > 0)
> > {
> > int start = 0;
> >
> > for (int i = 0; i < delegates.Length; i++, start++)
> > {
> > if (delegates[i] != null)
> > break;
> > }
> >
> > if (start == delegates.Length)
> > throw new ArgumentException("No valid delegate in
> > invocation list.", "strongDelegate");
> >
> > if (delegates[start].Target != null)
> > _weakTarget = new WeakReference(delegates[start].Target);
> >
> > _method = delegates[start].Method;
> >
> > WeakMulticastDelegate current = this;
> >
> > for (int i = start + 1; i < delegates.Length; i++)
> > {
> > if (delegates[i] != null)
> > {
> > current._next = new WeakMulticastDelegate(delegates[i].Target,
> > delegates[i].Method);
> > current = current._next;
> > }
> > }
> > }
> > }
> >
> > Thanks !
> >
> > Sébastien
> >
> > --
> > Sébastien Lorion
> > Software Architect / Architecte organique [EMAIL PROTECTED]
> >
> > ===================================
> > This list is hosted by DevelopMentor(r) http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
> >
>
> ===================================
> This list is hosted by DevelopMentor(r) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
--
Sébastien Lorion
Software Architect / Architecte organique
[EMAIL PROTECTED]
--
Sébastien Lorion
Software Architect / Architecte organique
[EMAIL PROTECTED]
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com