The Walk (English) Dual Audio 720p (1.39 GB) 1080p (2.61 GB). The Walk (Hindi) dual audio 720p.
Category:Lists of movies by language
Category:Lists of Indian television series episodesQ:
Lambda being executed multiple times
I have the following class,
class TestClass
{
public TestClass(Stream stream)
{
_data = File.ReadAllLines(stream.Position.ToString());
}
public string Data { get; private set; }
public void Execute(Func process)
{
var result = process(Data);
Data = result.ToArray().Concat(Data).ToString();
Console.WriteLine("Data processed");
}
}
I'm executing the following call,
TestClass test = new TestClass(File.OpenRead("1.txt"));
test.Execute(() => File.ReadAllLines("1.txt").ToArray());
The issue is that the lambda is being executed twice, once for each call to.Execute
The output is:
Data processed
Data processed
What I want is:
Data processed
Data processed
Data processed
Data processed
Data processed
Data processed
Data processed
Is there a way to prevent this behaviour? I just want the lambda to be called once, or can I somehow execute the function only once and pass the result as a parameter to the.Execute method?
A:
I'm a bit confused by this, because the example you posted works fine as written:
class TestClass
{
public TestClass(Stream stream)
{
_data = File.ReadAllLines(stream.Position.ToString());
}
public string Data { get; private set; }
public void Execute(Func process)
{
var result = process(Data); be359ba680
Related links:
Comments