示例#1
0
        public void Main()
        {
            source = new Source(this);

            loop = CFRunLoop.Current;
            loop.AddSource(source, CFRunLoop.ModeDefault);

            context = new Context(this);
            SynchronizationContext.SetSynchronizationContext(context);

            readyEvent.Set();

            loop.Run();

            cts.Dispose();
            source.Dispose();
        }
示例#2
0
 void eventTapThread()
 {
     tapThread = CFRunLoop.Current;
     tapThread.AddSource(eventPortSource, CFRunLoop.ModeCommon);
     tapThread.Run();
 }
示例#3
0
		CFSocket (int family, int type, int proto, CFRunLoop loop)
		{
			var cbTypes = CFSocketCallBackType.DataCallBack | CFSocketCallBackType.ConnectCallBack;

			gch = GCHandle.Alloc (this);
			var ctx = new CFStreamClientContext ();
			ctx.Info = GCHandle.ToIntPtr (gch);

			var ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(CFStreamClientContext)));
			try {
				Marshal.StructureToPtr (ctx, ptr, false);
				handle = CFSocketCreate (
					IntPtr.Zero, family, type, proto, cbTypes, OnCallback, ptr);
			} finally {
				Marshal.FreeHGlobal (ptr);
			}

			if (handle == IntPtr.Zero)
				throw new CFSocketException (CFSocketError.Error);
			gch = GCHandle.Alloc (this);

			var source = new CFRunLoopSource (CFSocketCreateRunLoopSource (IntPtr.Zero, handle, 0));
			loop.AddSource (source, CFRunLoop.CFDefaultRunLoopMode);
		}