说:**指令引用的**内存,该内存不能为read
在网上搜了一下,说 因为delegate委托一会自己就释放了,而我的函数里却一直在用他,放在很多个线程里用它
请问,怎么解决?
public delegate void CallBack(IntPtr a);
namespace DLLThreadPool
{
class Program
{
[DllImport("DLLDemo.dll", CharSet = CharSet.Auto)]
public static extern Int32 funcThreadPool(Int32 nPoolJobList, Int32 nPoolJobNum, Int32 nPoolThreadNum, CallBack cBack);
public static void fun_type1(IntPtr iPtr)
{
Thread.Sleep(50);
return ;
}
public static void Main(string[] args)
{
CallBack cb=new CallBack(Program.fun_type1);
int i = funcThreadPool(1000, 10000, 500, cb);
}
}
}