Пример #1
0
 private static void ServerOnMessageReceived(object sender, SettingsPersistenceMessage message)
 {
     try
     {
         Settings.UserSettings.All.SaveFromAnotherInstance(message.Serialized, message.IsLocal);
     }
     catch (Exception e)
     {
         LogWriter.Log(e, "Unable to execute arguments from IPC.");
     }
     finally
     {
         UnregisterServer();
     }
 }
Пример #2
0
    public static void SendMessage(int processId, string serialized, bool isLocal)
    {
        try
        {
            using var pipe = new NamedPipeClientStream(".", PipeName + processId, PipeDirection.Out);
            pipe.Connect();

            var message = new SettingsPersistenceMessage
            {
                Serialized = serialized,
                IsLocal    = isLocal
            };
            var buffer = JsonSerializer.SerializeToUtf8Bytes(message);

            pipe.Write(buffer, 0, buffer.Length);
        }
        catch (Exception e)
        {
            LogWriter.Log(e, "It was not possible to send a message via the IPC server.");
        }
    }