473,387 Members | 1,722 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,387 software developers and data experts.

ThreadStart with parameter.

Hello,

Can someone explain to me why are we not allowed to have a parameter on the
ThreadStart delegate? Does anyone know the design decision behind this
feature? This, IMO, rather annoying when we want to create a quick thread to
execute a function.

Thanks,

Victor
Jul 21 '05 #1
2 9332
Hi Victor,

Did you consider using delegates for this purpose?
Anyway, you might read this fine article from Jon Skeet:

Starting threads with parameters in C#
http://www.yoda.arachsys.com/csharp/threadstart.html
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Victor Hadianto" <sy***@nospam.nospam> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
Hello,

Can someone explain to me why are we not allowed to have a parameter on
the ThreadStart delegate? Does anyone know the design decision behind this
feature? This, IMO, rather annoying when we want to create a quick thread
to execute a function.

Thanks,

Victor

Jul 21 '05 #2
Victor Hadianto <sy***@nospam.nospam> wrote:
Can someone explain to me why are we not allowed to have a parameter on the
ThreadStart delegate? Does anyone know the design decision behind this
feature? This, IMO, rather annoying when we want to create a quick thread to
execute a function.


I don't know why in terms of a design decision, but here is a page of
workarounds:

http://www.pobox.com/~skeet/csharp/t...rameters.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
3
by: Maxime | last post by:
Can put a method with parameter in the ThreadStart ? Thread bThread = new Thread(new ThreadStart(Function(Parameter))); // Not Ok why? another way maybe ? Max
4
by: Fernando Rodríguez | last post by:
Hi, ThreadStart doesn't take any parameters. How can I create threads that take parameters? O:-) Thanks
2
by: Victor Hadianto | last post by:
Hello, Can someone explain to me why are we not allowed to have a parameter on the ThreadStart delegate? Does anyone know the design decision behind this feature? This, IMO, rather annoying when...
2
by: StefanS | last post by:
Hi all I'm stuck with a problem and hope someone can provide some hints on what I'm doing wrong. All I want to do ist start a thread which will sleep until a specified time and then wake up...
2
by: Ryan Liu | last post by:
How a thread is reused in thread pool? Change the context and call theThread.Run() again, and it executes same threadStart? Thanks! Ryan
4
by: Mike P | last post by:
How do you pass your parameters to the method you have specified for the threadstart? System.Threading.ThreadStart thdStart = new System.Threading.ThreadStart(MoveMail(new object { progress,...
1
by: robparr | last post by:
Hello, hopefully someone can help me. I am reading and learning steadily about threading and asynchronous programming, which to me sound like the same thing. At the moment I am not sure what the...
1
by: ktrvnbq02 | last post by:
Hi, I recently came to debug some old code that was causing a StackOverflowException. The code in question makes significant use of recursion and with large data structures it exhausted the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.