Пример #1
0
 public void Initialize()
 {
     StaticHelpers.LogToDebug($"{nameof(IthVnrSharpLib)}.{nameof(EmbedHost)}.{nameof(Initialize)}");
     try
     {
         _pipeServer      = new NamedPipeServerStream(PipeName, PipeDirection.InOut, NamedPipeServerStream.MaxAllowedServerInstances);
         _listeningThread = new Thread(async() => await ServerThread())
         {
             Name = PipeHostThreadName
         };
         _listeningThread.Start();
     }
     catch (Exception ex)
     {
         StaticHelpers.LogToFile(ex);
     }
     Initialized = true;
 }
Пример #2
0
        public async Task <bool> SendSettings()
        {
            if (!_pipeServer.IsConnected)
            {
                return(false);
            }
            try
            {
                var data     = GetDataBytes("settings", new EmbedSettings());
                var allBytes = BitConverter.GetBytes(data.Length).Reverse().Concat(data).ToArray();
                await _pipeServer.WriteAsync(allBytes, 0, allBytes.Length, _threadToken.Token);

                return(true);
            }
            catch (Exception ex)
            {
                StaticHelpers.LogToFile(ex);
                return(false);
            }
        }