473,246 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

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 8263
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aquila Deus | last post by:
Hi all! I found a problem when using generic with delegate: delegate RT MethodTemplate <RT> (); delegate RT MethodTemplate <RT, AT0> (AT0 a0); delegate RT...
3
by: brian c | last post by:
************************************** //Load the Assembly Assembly a = Assembly.LoadFrom(sAssembly); //Get Types so we can Identify the Interface. Type mytypes = a.GetTypes(); BindingFlags...
4
by: Robert Zurer | last post by:
Hello All, Is it considered a best practice to always write a parameterless constructor for any object - just in case? I'm not sure. I want my object to have all it absolutely requires to...
2
by: Ray Tayek | last post by:
hi, trying to make an array of function pointers to make delegates with. but the compiler does not like: void (Foo::^p)()=&Foo::bar; i did find an article that showed how to convert a delegate to...
12
by: Ole Nielsby | last post by:
Why is this? I've stumbled on this restriction more than once, and I'd like to know the philosophy behind it if there is one. I figure I'd be less prone to make this error if I knew the reason....
1
by: Nathan Sokalski | last post by:
I have created a custom control for ASP.NET using VB.NET. My control inherits from the System.Web.UI.WebControls.CompositeControl class, and is working fine. However, the Visual Studio .NET designer...
2
by: Hans Kesting | last post by:
on 23-9-2008, Julia B supposed : Usually that errormessage means that you derived a class from a baseclass that has no parameterless constructors. Always when you call a constructor, a...
2
by: bednarz.thomas | last post by:
I have the following business Object(s): public class ParentObject { public ParentObject(string somestring) { ...- } ....
9
by: puzzlecracker | last post by:
"The C# specification states that all value types have a default parameterless constructor, and it uses the same syntax to call both explicitly declared constructors and the parameterless one,...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.