using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; namespace thread02 { public delegate bool MyDelegate(int i, string str); class Program { static void Main(string[] args) { Console.WriteLine("testing threading concept:"); MyDelegate delInstance = new MyDelegate(MyFunction); IAsyncResult ref = delInstance.BeginInvoke(100,"I am in Delegate Thread", null, null); //<== can not compile at this statement for (int i = 0; i < 100; i++) Console.WriteLine("I am in Main Thread {0}", i); bool status = delInstance.EndInvoke(ref); Console.ReadKey(); } public static bool MyFunction(int count, string str) { for (int i = 0; i < count; i++) Console.WriteLine(str + " {0}", i); return true; } } }
Error CS0119 'IAsyncResult' is a type, which is not valid in the given context
ref
IAsyncResult ref = delInstance.BeginInvoke(100,"I am in Delegate Thread", null, null);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)