/// <summary> /// Create an IPC server and start listening for connection. /// </summary> /// <param name="serverName"> /// Name to assign to IPC server. /// </param> /// <param name="writeThrough"> /// If true writes will bypass system cache and go straight to the pipe. /// </param> /// <returns>Index of server created.</returns> internal static int CreateServer(string serverName, bool writeThrough) { if (Count >= myMaxServerCount) { throw new ApplicationException("Maximum number of IPC servers exceeded."); } if (myServerList != null) { for (int x = 0; x < myServerList.Length; x++) { if (myServerList[x] == null) { Count++; ServerInstance si = new ServerInstance(serverName, writeThrough, x, myMaxServerCount); Interlocked.Exchange <ServerInstance>(ref myServerList[x], si); return(x); } } } throw new ApplicationException("Error creating new IPC server."); }
internal static bool GetServer(int index, out ServerInstance serverInstance) { serverInstance = ThreadHelper.VolatileRead <ServerInstance>(ref myServerList[index]); return(serverInstance == null ? false : true); }