Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

NSPort Solution

$
0
0

I am looking at example https://developer.xamarin.com/samples/mac/NSPortExample/

I am trying to recreate the Obj-C code into c# but I am not having any success.

Below is my simple version of the Obj-C , can anyone tell me what I am doing wrong, please.

static class MainClass
    {
        static void Main(string[] args)
        {
            NSApplication.Init();
            var localPost = CFMessagePort.CreateLocalPort("com.example.app.port.server", HandleCFMessagePortCallBack, CFAllocator.Default);
            CFRunLoopSource runSource = localPost.CreateRunLoopSource();
            CFRunLoop.Current.AddSource(runSource, (NSString)string.Empty);
            while(true){}
        }
        static NSData HandleCFMessagePortCallBack(int type, NSData data)
        {
            Console.WriteLine("Data:{0}",data);
            return new NSData();
        }
    }

Viewing all articles
Browse latest Browse all 1429

Trending Articles