469,302 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,302 developers. It's quick & easy.

Parameterless void delegate?

Hi,

Does the Framework provide a standard void, parameterless delegate?
Something like ThreadStart but without the implication that it will be used
to start a thread?

Shak
Jul 3 '07 #1
7 8107
You can roll your own. Why would you need for the Framework to provide that?


"Shak" <me@privacy.netwrote in message
news:5e*************@mid.individual.net...
Hi,

Does the Framework provide a standard void, parameterless delegate?
Something like ThreadStart but without the implication that it will be
used to start a thread?

Shak

Jul 3 '07 #2
On Jul 3, 3:33 pm, "Bob Johnson" <A...@B.COMwrote:
You can roll your own. Why would you need for the Framework to provide that?
It's a simply one liner but many applications need it sooner or later
so it would nice to have a common type so that future merging of code
doesn't create overlaps. I don't know why they couldn't have just
called the ThreadStart delegate VoidFunction and then everyone would
be happy.

Jul 3 '07 #3
Israel <is**********@hotmail.comwrote:
On Jul 3, 3:33 pm, "Bob Johnson" <A...@B.COMwrote:
You can roll your own. Why would you need for the Framework to provide that?

It's a simply one liner but many applications need it sooner or later
so it would nice to have a common type so that future merging of code
doesn't create overlaps. I don't know why they couldn't have just
called the ThreadStart delegate VoidFunction and then everyone would
be happy.
I have to say I've wished for this too - Action<Tis nice and general,
but when you don't need any parameters, it's a bit silly...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 3 '07 #4
It is a real shame that MethodInvoker was placed in
System.Windows.Forms and not System.ComponentModel (and System.dll).
Although I guess any utility dll could donate such...

I guess since it is only a name ThreadStart should suffice, but then
you confuse people into thinking that threading is involved, when it
is just a callback (or similar). I don't see much benefit in declaring
another void() delegate just to clarify this, but I do get sick of
adding the comment:
// just a callback - no threading here...
ThreadStart callback = SomeMethod;

Marc
Jul 4 '07 #5
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Israel <is**********@hotmail.comwrote:
>On Jul 3, 3:33 pm, "Bob Johnson" <A...@B.COMwrote:
You can roll your own. Why would you need for the Framework to provide
that?

It's a simply one liner but many applications need it sooner or later
so it would nice to have a common type so that future merging of code
doesn't create overlaps. I don't know why they couldn't have just
called the ThreadStart delegate VoidFunction and then everyone would
be happy.

I have to say I've wished for this too - Action<Tis nice and general,
but when you don't need any parameters, it's a bit silly...
And it's in System, which is cool. But then even Action<Tbrings baggage
with it. Well, if you read the docs it does anyway.

Shak
Jul 4 '07 #6
Shak <me@privacy.netwrote:
I have to say I've wished for this too - Action<Tis nice and general,
but when you don't need any parameters, it's a bit silly...

And it's in System, which is cool. But then even Action<Tbrings baggage
with it. Well, if you read the docs it does anyway.
I've just looked at the docs and I don't understand what baggage you're
talking about - could you elaborate?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 4 '07 #7
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Shak <me@privacy.netwrote:
I have to say I've wished for this too - Action<Tis nice and general,
but when you don't need any parameters, it's a bit silly...

And it's in System, which is cool. But then even Action<Tbrings baggage
with it. Well, if you read the docs it does anyway.

I've just looked at the docs and I don't understand what baggage you're
talking about - could you elaborate?
It seems to have been specifically created for the ForEach method on
collections etc. This doesn't affect its use of course, but then it could
lead people reading my code down the wrong path anyway; you may as well just
use ThreadStart instead.

Shak
Jul 5 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Aquila Deus | last post: by
4 posts views Thread by Robert Zurer | last post: by
2 posts views Thread by Hans Kesting | last post: by
9 posts views Thread by puzzlecracker | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.