internal static int AddConnectionListener(ConnectionListenerFunction callback, bool immediateNotify) { Interop.NT_ConnectionListenerCallback modCallback = (uint uid, IntPtr data, int connected, ref NtConnectionInfo conn) => { string remoteName = ReadUTF8String(conn.RemoteName); ConnectionInfo info = new ConnectionInfo(conn.RemoteId.ToString(), remoteName, (int)conn.RemotePort, (long)conn.LastUpdate, (int)conn.ProtocolVersion); callback((int)uid, connected != 0, info); }; int retVal = (int)Interop.NT_AddConnectionListener(IntPtr.Zero, modCallback, immediateNotify ? 1 : 0); s_connectionCallbacks.Add(retVal, modCallback); return(retVal); }