[Gtk-sharp-list] "format-value" signal in Gtk.Scale

Gonzalo Paniagua Javier gonzalo@ximian.com
11 Mar 2003 19:08:16 +0100

El mar, 11 de 03 de 2003 a las 18:05, Miguel de Icaza escribió:
> > Well, if anyone can convince me with documentation that non-void
> > delegates as events are being used safely and effectively elsewhere in
> > .net, I'd consider changing this.  I think the current method will be
> > least confusing to people familiar with .net paradigms, and I'm also not
> > convinced that using non-void delegates for events is correct.
> The construct is allowed in .NET, it does have the same semantics than
> the current RetVal approach in the presence of multiple signals.
> Another thing to keep in mind is that in Glib there is a notion of
> "stopping" an emission, to address issues like this.  Mathieu's Lacage
> document on GLib object and signals is interesting:
> 	http://www.gnome.org/~mathieu/gobject/main.html

> Gtk has a few ways of dealing with multiple-return values:
> 	* Accumulators
> 	* If no accumulators are present, the result is the result of
> 	  the last signal invoked.
> I am not sure if we could even think about doing something like this
> with the delegate/event infrastructure in .NET.  We can *stop* an
> emision from GLib/Gtk, but we could not stop the signal from being
> propagated to other delegates on the MulticastDelegate event chain.

If we add a StopEmitting boolean property to SignalArgs and we invoke
the delegates like:
	object[] argv = new object[2];
	argv[0] = inst._obj;
	argv[1] = args;

	foreach (XXXSignal signal in inst._obj.GetInvocationList ()) {
		signal.DynamicInvoke (argv);
		if (args.StopEmission)

we can stop calling other delegates if one of them requests it.

We can also add an Accumulator property and deal with it after each
invocation in presence of a GSignalAccumulator.

I also prefer the .NET way of doing this. For example, implementing
automatic event wire up in System.Web is much easier as I don't have to
check each of the (many) possible event signatures: all the event
handlers have the same signature.

-Gonzalo / just my 2c