예제 #1
0
        public WorkerResult StartUnmanaged()
        {
            WorkerResult ret = null;
            Unmanaged worker = new Unmanaged();
            Semaphore locker = new Semaphore(0, 1);

            worker.OnCallback += (IEntity param) =>
            {
                ret = param as WorkerResult;

                if (ret == null)
                {
                    Console.WriteLine("erro no cast!");
                }
                else
                {
                    Console.WriteLine("Id da classe: {0}", ret.Id);
                }
                locker.Release();
            };

            worker.DoSomething(2);
            Console.WriteLine("Chamou o Unmanaged....");

            locker.WaitOne();

            return ret;
        }