Saw the code here. Can any one tell me what it means?
Action wrappedAction = () =>
{
threadToKill = Thread.CurrentThread;
action();
};
Can we write such code with .net v2.0...?
Saw the code here. Can any one tell me what it means?
Action wrappedAction = () =>
{
threadToKill = Thread.CurrentThread;
action();
};
Can we write such code with .net v2.0...?
That is a lambda expression, and is only available in C# 3.0+. The C# 2.0 version of that code looks like this:
Action wrappedAction = delegate()
{
threadToKill = Thread.CurrentThread;
action();
};
Assuming you have declared the Action delegate previously.
It means that wrapAction
is a delegate, that takes in no parameter and that executes the following code block
threadToKill = Thread.CurrentThread;
action();
It s equivalent to
public delegate void wrapActionDel();
public void wrapAction()
{
threadToKill = Thread.CurrentThread;
action();
}
public void CallwrapAction()
{
wrapActionDel del = wrapAction;
del ();
}
You can see that this is verbose, but Action
is not.
And, this is only available in .Net 3.5. Don t worry, your .net 2.0 code will work seamlessly with .net 3.5, so you can just upgrade.
Asiento ******** Id_Asiento integer key Fecha date It_Asiento ********** Id_Asiento integer Forenkey Importe float I wan to do This SQL Query with Linq select Asiento.Id_Asiento, ...
I have code listed here: Threading and Sockets. The answer to that question was to modify isListening with volatile. As I remarked, that modifier allowed me to access the variable from another thread....
Is their a way in c# to instantiate a variable into a method call without using a switch statement.
Saw the code here. Can any one tell me what it means? Action wrappedAction = () => { threadToKill = Thread.CurrentThread; action(); }; Can we write such code with ...
I m sure this is simple but it s driving me nuts. I have a ListBox on my page to show artists, which calls a method when the index is changed, and a button which loads an artist from that list in ...
How to cancel an asynchronous call? The .NET APM doesn t seem to support this operation. I have the following loop in my code which spawns multiple threads on the ThreadPool. When I click a button on ...
I have a section of code that looks like this: try { classVar = functionCall(input, sEnum.First); classVar = functionCall(input, sEnum.Second); classVar = functionCall(input, sEnum.Third); } ...
I have done my project and now it is documentation time. Up to now I was able to generate the XML files from the project. Now I want to get the HTML API out of it. But I can t figure it out.