using System; using System.IO; using System.Runtime.InteropServices; using System.Threading; using System.Runtime; using System.Reflection; namespace NativeLibConsumeApp { class Program { public delegate void CallBackDelegate(int a, int b); [DllImport("CallbackThreadSample.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void GetData(); [DllImport("CallbackThreadSample.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetCallback(CallBackDelegate aCallback); static void Main(string[] args) { CallBackDelegate lTD = new CallBackDelegate(Program.Callback); SetCallback(lTD); //Sets up the callback int thread = Thread.CurrentThread.ManagedThreadId; GetData(); //This calls the callback in unmanaged code // while (true) ; } //Callback function which is called from the unmanaged code public static void Callback(int a, int b) { Console.WriteLine("A: {0} B: {1}", a, b); int thread = Thread.CurrentThread.ManagedThreadId; } } }
PWorker worker = null; if( IsWindow() { worker = new WindowWorker(); } else { worker = new LinuxWorker(); } work.DoMyWork();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)