Beispiel #1
0
 /// <summary>
 /// Starts a server dictionary, which client dictionaries in other processes can then access.
 /// </summary>
 public static void StartServer()
 {
     lock (syncLock)
     {
         if (dictionary == null)
         {
             dictionary = new ServerDictionary();
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Starts a client dictionary to connect to the server.
 /// </summary>
 public static void StartClient()
 {
     lock (syncLock)
     {
         if (dictionary == null)
         {
             dictionary = new ClientDictionary();
             PipeSmokeTest();
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// After you are done with a dictionary session, you *should* close it.
 /// Behavior is undefined & unsupported if you leave the pipe open.
 /// </summary>
 public static void Close()
 {
     lock (syncLock)
     {
         if (dictionary == null)
         {
             throw new InvalidOperationException("A dictionary does not exist.");
         }
         ((IDisposable)dictionary).Dispose();
         dictionary = null;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Starts a Dictionary when you don't know if you should be server or client.
 /// This is a mechanism to avoid ----ing up tests, but it causes issues, such as us having to ---- an exception.
 /// Don't use it if you don't have to.
 /// </summary>
 private static void StartUnknown()
 {
     lock (syncLock)
     {
         if (dictionary == null)
         {
             Trace.WriteLine("Warning to Tester - You should be using the Explicit DictionaryStore.StartServer()/StartClient() API.");
             //Connect to a server if one is present, otherwise, take the initiative and be the server!
             try
             {
                 StartClient();
             }
             catch (Exception) //
             {
                 dictionary.Dispose();
                 dictionary = null;
                 StartServer();
             }
         }
     }
 }