1) I heard that when we do not call EndInvoke (), it can lead to a memory leak? can you demonstrate this, how can this lead to a memory leak?
2) When I intend to call EndInvoke (), should I use the code as shown below?
namespace BlockMechanism
{
public delegate int MyDelegate(List<int> someInts);
class MainClass
{
static void Main()
{
List<int> someInts = new List<int> { 1, 2, 3, 4, 5, 6, 7 };
MyDelegate test = FinalResult;
IAsyncResult res=test.BeginInvoke(someInts, null, test);
Console.WriteLine(test.EndInvoke(res));
Console.ReadKey(true);
}
public static int FinalResult(List<int> Mylist)
{
return Mylist.Sum();
}
}
}
source
share